def __init__(self, screen, config, startClock): super(RobotRunScene, self).__init__(screen, config, startClock) self.w, self.h = self.screen.get_width(), self.screen.get_height() self.__As_MAP = AStarArea(Rectangle(0, 0, 800, 600), 80, 60) self.caption = 'Actor与A*结合测试场景' self.__containers = [] for i in range(0, 6): x = int(random.randint(100, self.w - 150) / 10) * 10 y = int(random.randint(100, self.h - 150) / 10) * 10 w = int(random.randint(50, 150) / 10) * 10 h = int(random.randint(50, 150) / 10) * 10 self.__containers.append(Container(Rectangle(x, y, w, h))) _x, _y = int(x / self.__As_MAP.unit_w), int(y / self.__As_MAP.unit_h) _w, _h = int(w / self.__As_MAP.unit_w), int(h / self.__As_MAP.unit_h) self.__As_MAP.addObstacleArea(_x, _w, _y, _h) self.__A_Robot = RobotActor(Rectangle(0, 0, 100, 100)) self.__E_Msg = TextElement((600, 0, 200, 60), 'Robotlocal:(0, 0)\nMouselocal:(0, 0)', gl_Font, 12, (255, 255, 255), 1) self.__E_Msg2 = TextElement((600, 40, 200, 600), 'Astart:\n', gl_Font, 10, (255, 255, 255), 1) self.__pathList = [] self.__normalLis = [] self.__build_As_Map() self.__i = 0 self.__end = (0, 0)
def __init__(self, screen, config, time): super(AstartTest, self).__init__(screen, config, time) self.cols, self.rows = 100, 100 self.grid = [] self.openSet, self.closeSet = [], [] self.start, self.end = None, None self.w, self.h = screen.get_width() / self.cols, screen.get_height( ) / self.rows self.path = [] self.done = False self.noSolution = False self.points = [] self.__E_TEXT = TextElement( pygame.Rect(centeredXPos(self.width, 220), 260, 220, 60), '', gl_Font, 50, (255, 255, 0), 1) for i in range(0, self.cols): self.grid.append([]) for i in range(0, self.cols): for j in range(0, self.rows): self.grid[i].append(Spot(i, j)) for i in range(0, self.cols): for j in range(0, self.rows): self.grid[i][j].addNeighbors(self.cols, self.rows, self.grid) self.start = self.grid[0][0] self.end = self.grid[self.cols - 1][self.rows - 1] self.start.wall = False self.end.wall = False self.openSet.append(self.start)
def __init__(self, screen, config, startClock): super(testSpriteScene, self).__init__(screen, config, startClock) self.img = pygame.Surface((5, 5)).convert() self.img.fill((255, 255, 255)) self.sprintsGroup1 = SpriteGroup(RectangleRange(0, 0, 800, 600)) self.__E_FPS = TextElement(pygame.Rect(self.width - 80, 0, 80, 20), 'FPS:', gl_Font, 18, (0, 255, 0), 1) for i in range(0, 1000): x, y = random.randint(0, 800), random.randint(0, 600) self.sprintsGroup1.add(CubeSprite(self.img, pygame.Rect(x, y, 5, 5)))
def __init__(self, *args): super(canvasTest, self).__init__(*args) # self.can = canvas(color(0, 0, 0), vec2(800, 600)) # self.brush = brush(self.can, (255, 255, 255, 0.5), 1) # self.painter = Painter(self.can.surface()) self.blend = pygame.Surface((300, 300)).convert() self.blend.fill((255, 255, 255)) self.blend.set_alpha(80) self.sceneCanvas = pygame.Surface((self.width, self.height)) self.sceneCanvas.fill((255, 255, 255)) self.sceneCanvas.set_alpha(100) self.__E_FPS = TextElement(pygame.Rect(self.width - 80, 0, 80, 20), 'FPS:', gl_Font, 18, (0, 255, 0), 1)
def __buildList(self): fs = [] import os for root, dirs, files in os.walk(RECORDFILE_SAVE_PATH): fs += files for name in fs: if name.find(RECORDFILE_SAVE_NAMEHEAD) == 0 and name.find(RECORDFILE_SAVE_EXN) > 0: n = name.replace(RECORDFILE_SAVE_EXN, '') dataList = RecordFile(RECORDFILE_SAVE_PATH, n).getList() if dataList is not None: self.__ElementsList.append( SaveDataElement((83, 30, 636, 114), gl_UIPath + self.__res_n_OPT, 255, dataList)) if len(self.__ElementsList) == 0: self.__ElementsList.append( (TextElement((centeredXPos(800, 220), centeredXPos(600, 35), 220, 35), '未找到游戏记录', gl_Font_oth, 30, (255, 255, 255, 255), self.config.getTextAntiAlias())))
def createTextElement(self, text="TextElement", pos=(0, 0), size=18, length=None, color=(255, 255, 255), font=gl_Font, zIndex=999): """ :param text: :param pos: 可以是int型数字代码, 0,上居中 :param size: :param length: :param color: :param font: :param zIndex: :return: """ if length is None: length = len(text) * size _top, _left = 0, self.nextElementY if isinstance(pos, tuple) or isinstance(pos, list): _top, _left = pos[0], self.nextElementY + pos[1] elif isinstance(pos, vec2): _top, _left = pos.x, self.nextElementY + pos.y elif isinstance(pos, int): _top, _left = self.__getPos(pos, length, size) e = TextElement((_top, _left, length * size + 2, size + 2), text, font, size, color, 1) e.zIndex = zIndex self.__CreatedElementList.append(e) self.__render.open() self.__render.add(e) self.__render.close() self.nextElementY += size + 4 self.id += 1 return e
def __init__(self, *args): super(pickTest, self).__init__(*args) self.__flag_isEnter = False self.__alpha = 0 self.__flag_recordStartTime = False self.__start_time = 0 self.__now_time = 0 self.res_Img_BG_Name = 'OPT_BG.bmp' self.res_Sound_Choose_Name = 'OPT_C.wav' self.res_UI_RightButton = 'OPT_BR.png' self.res_UI_LeftButton = 'OPT_BL.png' self.__Clock = pygame.time.Clock() self.__KV_AA = {} self.__KV_WAVE = {} self.__ElementsMap = {} if self.config.getTextAntiAlias(): self.__KV_AA['key'] = '开' self.__KV_AA['val'] = '1' else: self.__KV_AA['key'] = '关' self.__KV_AA['val'] = '0' self.res_Sound_Choose = pygame.mixer.Sound(gl_SoundPath + self.res_Sound_Choose_Name) self.res_Sound_Choose.set_volume(self.config.getVolumeSound()) self.res_Img_BG = pygame.image.load(gl_ImgPath + self.res_Img_BG_Name) self.__E_BGBlankL1 = OptButtonElement((40, 60, 200, 40), (255, 255, 255, 100)) self.__E_BGBlankL2 = OptButtonElement((40, 110, 200, 40), (255, 255, 255, 100)) self.__E_BGBlankL3 = OptButtonElement((40, 160, 200, 40), (255, 255, 255, 100)) self.__E_BGBlankLRet = OptButtonElement((50, 520, 80, 40), (255, 255, 255, 100)) self.__E_BGBlankLApply = OptButtonElement((150, 520, 80, 40), (255, 255, 255, 100)) self.__E_BGBlankR = TitleConstElement( (260, 60, 510, 500), blankSurface((510, 500), (255, 255, 255, 100))) self.__E_Text_Apply = TextElement( (centeredXPos(80, 40, 150), centeredYPos(40, 20, 520), 120, 20), '应用', gl_Font_opt, 20, (0, 0, 0), self.config.getTextAntiAlias()) self.__E_Text_Apply.zIndex = 1 self.__E_Text_Ret = TextElement( (centeredXPos(80, 40, 50), centeredYPos(40, 20, 520), 120, 20), '返回', gl_Font_opt, 20, (0, 0, 0), self.config.getTextAntiAlias()) self.__E_Text_Ret.zIndex = 1 self.__E_Text_Draw = TextElement( (centeredXPos(200, 80, 40), centeredYPos(40, 20, 60), 80, 20), '画面设置', gl_Font_opt, 20, (0, 0, 0), self.config.getTextAntiAlias()) self.__E_Text_Draw.zIndex = 1 self.__E_Text_AntiAlias = TextElement((270, 70, 120, 20), '抗锯齿:', gl_Font_opt, 18, (0, 0, 0), self.config.getTextAntiAlias()) self.__E_Text_AntiAlias.zIndex = 1 self.__E_Text_AA_Val = TextElement( (670, 70, 20, 20), self.__KV_AA['key'], gl_Font_opt, 18, (0, 0, 0), self.config.getTextAntiAlias()) self.__E_Text_AA_Val.zIndex = 1 self.__E_UI_AA_RightButton = OptUIElement( (700, 70, 20, 20), gl_UIPath + self.res_UI_RightButton) self.__E_UI_AA_RightButton.zIndex = 1 self.__E_UI_AA_LeftButton = OptUIElement( (640, 70, 20, 20), gl_UIPath + self.res_UI_LeftButton) self.__E_UI_AA_LeftButton.zIndex = 1 self.__E_Text_Wave = TextElement( (centeredXPos(200, 80, 40), centeredYPos(40, 20, 110), 80, 20), '声音设置', gl_Font_opt, 20, (0, 0, 0), self.config.getTextAntiAlias()) self.__E_Text_Wave.zIndex = 1 self.__E_Text_BGMVolume = TextElement((270, 70, 120, 20), '音乐音量:', gl_Font_opt, 18, (0, 0, 0), self.config.getTextAntiAlias()) self.__E_Text_BGMVolume.zIndex = 1 self.__E_Text_BGM_Val = TextElement((660, 70, 30, 20), str(self.config.VolumeBGM), gl_Font_opt, 18, (0, 0, 0), self.config.getTextAntiAlias()) self.__E_Text_BGM_Val.zIndex = 1 self.__E_UI_BGM_RightButton = OptUIElement( (700, 70, 20, 20), gl_UIPath + self.res_UI_RightButton) self.__E_UI_BGM_RightButton.zIndex = 1 self.__E_UI_BGM_LeftButton = OptUIElement( (630, 70, 20, 20), gl_UIPath + self.res_UI_LeftButton) self.__E_UI_BGM_LeftButton.zIndex = 1 self.__E_Text_SoundVolume = TextElement((270, 100, 120, 20), '音效音量:', gl_Font_opt, 18, (0, 0, 0), self.config.getTextAntiAlias()) self.__E_Text_SoundVolume.zIndex = 1 self.__E_Text_Sou_Val = TextElement((660, 100, 30, 20), str(self.config.VolumeSound), gl_Font_opt, 18, (0, 0, 0), self.config.getTextAntiAlias()) self.__E_Text_Sou_Val.zIndex = 1 self.__E_UI_Sou_RightButton = OptUIElement( (700, 100, 20, 20), gl_UIPath + self.res_UI_RightButton) self.__E_UI_Sou_RightButton.zIndex = 1 self.__E_UI_Sou_LeftButton = OptUIElement( (630, 100, 20, 20), gl_UIPath + self.res_UI_LeftButton) self.__E_UI_Sou_LeftButton.zIndex = 1 self.__E_Text_Licence = TextElement( (centeredXPos(200, 120, 40), centeredYPos(40, 20, 160), 120, 20), '开源软件许可', gl_Font_opt, 20, (0, 0, 0), self.config.getTextAntiAlias()) self.__E_Text_Licence.zIndex = 1 self.__E_Img_Licence = ImgElement(self.__E_BGBlankR.area, gl_ImgPath + 'OPT_L.lice', 255, (128, 128, 128)) self.__E_Img_Licence.zIndex = 1 # 画面设置绑定事件 self.__E_BGBlankL1.Events.appendEvent( ioEvent3Enum.mouseLeftKeyDown, lambda: ChePos(self.__E_Text_Draw, True), 1) self.__E_BGBlankL1.Events.appendEvent( ioEvent3Enum.mouseLeftKeyDown, lambda: self.__rebuildElementsToList2([ self.__E_Text_AntiAlias, self.__E_Text_AA_Val, self. __E_UI_AA_RightButton, self.__E_UI_AA_LeftButton ]), 2) self.__E_BGBlankL1.Events.appendEvent( ioEvent3Enum.mouseLeftKeyUp, lambda: ChePos(self.__E_Text_Draw, False), 1) # 声音设置绑定事件 self.__E_BGBlankL2.Events.appendEvent( ioEvent3Enum.mouseLeftKeyDown, lambda: ChePos(self.__E_Text_Wave, True), 1) self.__E_BGBlankL2.Events.appendEvent( ioEvent3Enum.mouseLeftKeyDown, lambda: self.__rebuildElementsToList2([ self.__E_Text_BGMVolume, self.__E_Text_SoundVolume, self. __E_Text_BGM_Val, self.__E_Text_Sou_Val, self. __E_UI_BGM_RightButton, self.__E_UI_BGM_LeftButton, self. __E_UI_Sou_RightButton, self.__E_UI_Sou_LeftButton ]), 2) self.__E_BGBlankL2.Events.appendEvent( ioEvent3Enum.mouseLeftKeyUp, lambda: ChePos(self.__E_Text_Wave, False), 1) # 开源软件许可按钮绑定事件 self.__E_BGBlankL3.Events.appendEvent( ioEvent3Enum.mouseLeftKeyDown, lambda: ChePos(self.__E_Text_Licence, True), 1) self.__E_BGBlankL3.Events.appendEvent( ioEvent3Enum.mouseLeftKeyDown, lambda: self.__rebuildElementsToList2([self.__E_Img_Licence]), 2) self.__E_BGBlankL3.Events.appendEvent( ioEvent3Enum.mouseLeftKeyUp, lambda: ChePos(self.__E_Text_Licence, False), 1) # 应用按钮绑定事件 self.__E_BGBlankLApply.Events.appendEvent( ioEvent3Enum.mouseLeftKeyDown, lambda: ChePos(self.__E_Text_Apply, True), 1) self.__E_BGBlankLApply.Events.appendEvent( ioEvent3Enum.mouseLeftKeyUp, lambda: ChePos(self.__E_Text_Apply, False), 1) self.__E_BGBlankLApply.Events.appendEvent( ioEvent3Enum.mouseLeftKeyClick, lambda: self.__retSignalIsReadyToEnd(SCENENUM_OPT_APPLY), 1) self.__E_BGBlankLApply.Events.appendEvent( ioEvent3Enum.mouseLeftKeyClick, lambda: self.__updConfig(), 2) # 返回按钮绑定事件 self.__E_BGBlankLRet.Events.appendEvent( ioEvent3Enum.mouseLeftKeyDown, lambda: ChePos(self.__E_Text_Ret, True), 1) self.__E_BGBlankLRet.Events.appendEvent( ioEvent3Enum.mouseLeftKeyUp, lambda: ChePos(self.__E_Text_Ret, False), 1) self.__E_BGBlankLRet.Events.appendEvent( ioEvent3Enum.mouseLeftKeyClick, lambda: self.__retSignalIsReadyToEnd(SCENENUM_TITLE), 1) # 抗锯齿UI按钮绑定事件 self.__E_UI_AA_LeftButton.Events.appendEvent( ioEvent3Enum.mouseLeftKeyClick, lambda: self.__chVal_AA_Txt(), 1) self.__E_UI_AA_RightButton.Events.appendEvent( ioEvent3Enum.mouseLeftKeyClick, lambda: self.__chVal_AA_Txt(), 1) # 改变音量UI按钮绑定事件 self.__E_UI_BGM_LeftButton.Events.appendEvent( ioEvent3Enum.mouseLeftKeyClick, lambda: self.__chVal_WaveParam_Txt( self.__E_Text_BGM_Val, False, GLC_INI_PARAM_BGMVOLUME), 1) self.__E_UI_BGM_RightButton.Events.appendEvent( ioEvent3Enum.mouseLeftKeyClick, lambda: self.__chVal_WaveParam_Txt( self.__E_Text_BGM_Val, True, GLC_INI_PARAM_BGMVOLUME), 1) self.__E_UI_Sou_LeftButton.Events.appendEvent( ioEvent3Enum.mouseLeftKeyClick, lambda: self.__chVal_WaveParam_Txt( self.__E_Text_Sou_Val, False, GLC_INI_PARAM_SOUNDVOLUME), 1) self.__E_UI_Sou_RightButton.Events.appendEvent( ioEvent3Enum.mouseLeftKeyClick, lambda: self.__chVal_WaveParam_Txt( self.__E_Text_Sou_Val, True, GLC_INI_PARAM_SOUNDVOLUME), 1) self.__ElementsMap['Draw1'] = [ self.__E_BGBlankL1, self.__E_BGBlankL2, self.__E_BGBlankL3, self.__E_BGBlankR, self.__E_Text_Draw, self.__E_Text_Wave, self.__E_Text_Licence, self.__E_BGBlankLApply, self.__E_Text_Apply, self.__E_BGBlankLRet, self.__E_Text_Ret ] self.__ElementsMap['Draw2'] = [ self.__E_Text_AntiAlias, self.__E_Text_AA_Val, self.__E_UI_AA_RightButton, self.__E_UI_AA_LeftButton ] self.__ElementsMap['Interact1'] = [ self.__E_BGBlankL1, self.__E_BGBlankL2, self.__E_BGBlankL3, self.__E_BGBlankLApply, self.__E_BGBlankLRet ] self.__ElementsMap['Interact2'] = [ self.__E_UI_AA_RightButton, self.__E_UI_AA_LeftButton ] self.__ElementsMap[ 'Draw'] = self.__ElementsMap['Draw1'] + self.__ElementsMap['Draw2'] self.__ElementsMap['Interact'] = self.__ElementsMap[ 'Interact1'] + self.__ElementsMap['Interact2'] self.render.add(self.__ElementsMap['Draw1']) self.render.add(self.__ElementsMap['Interact']) self.render.close() # 设定渲染参数 self.__step = 4 self.__frameRate = self.config.getFrameRate() if self.__frameRate: self.__step = 255 / (1.5 * self.__frameRate)
def __init__(self, *args): # 注册场景 super().__init__(*args) self.useDefaultDraw = False from source.config.AppConfig import registerScene registerScene(SCENENUM_GAME_PROLOGUE, Title_PrologueScene) registerScene(SCENENUM_OPT, OptionScene) registerScene(SCENENUM_CONTINUE, Continue_Scene) self.alpha = 0 self.flag = False self.isMusicPlay = False self.wave_bgm = 'titleBackground.wav' self.titleBgName = 'titleBg.bmp' self.titleOptionName = 'titleOpts.bmp' self.titleName = 'titleTop.bmp' self.__res_s_cloud = 'T_S_C.png' self.__ast_name = 'I_T.assets' self.res_wave_bgm = pygame.mixer.Sound(gl_MusicPath + self.wave_bgm) self.res_wave_bgm.set_volume(self.config.getVolumeBGM()) self.bg = pygame.image.load(gl_ImgPath + self.titleBgName) self.res_optionNewGame = pygame.image.load(gl_ImgPath + self.titleOptionName) self.res_title = pygame.image.load(gl_ImgPath + self.titleName) self.__frameRate = self.config.getFrameRate() self.__expBoardText = AssetsFile(os.path.join(gl_AssetsPath, 'TitleScene')).decode( self.__ast_name, AssetsType.EXP) # 创建相应的Element self.__board = TitleConstElement((gl_WindowWidth - 380, gl_WindowHeight - 80, 380, 80), blankSurface((380, 180), (255, 255, 255, 100))) self.__title = TitleConstElement((0, 0, 465, 74), clipResImg(self.res_title, (0, 0, 465, 74), (0, 0, 0))) self.__text = TextElement((gl_WindowWidth - 380, gl_WindowHeight - 80, 380, 80), self.__expBoardText[0], gl_Font, 16, (0, 0, 0), self.config.getTextAntiAlias()) self.__optNewGame = TitleOptElement((140, 140, 116, 30), self.res_optionNewGame, (0, 0, 116, 30), (128, 128, 128)) self.__optContinue = TitleOptElement((125, 180, 116, 30), self.res_optionNewGame, (0, 116, 116, 30), (128, 128, 128)) self.__optOption = TitleOptElement((130, 220, 116, 30), self.res_optionNewGame, (0, 232, 116, 30), (128, 128, 128)) self.__optExit = TitleOptElement((135, 260, 61, 30), self.res_optionNewGame, (0, 348, 61, 30), (128, 128, 128)) self.__spriteCloud = ImgElement((801, -120, 750, 396), gl_ImgPath + self.__res_s_cloud) self.__spriteCloud.zIndex = -1 self.__step = 1 self.render.add(self.__board, self.__title, self.__text, self.__optNewGame, self.__optContinue, self.__optOption, self.__optExit) self.render.close() # 这里绑定和控件有交互的事件 # ---NewGame选项绑定事件--- self.__optNewGame.Events.appendEvent(ioEvent3Enum.mouseLeftKeyClick, lambda: self.__retSignalIsReadyToEnd(SCENENUM_GAME_PROLOGUE), 1) self.__optNewGame.Events.appendEvent(ioEvent3Enum.mouseIn, lambda: self.__changeBoardText(self.__expBoardText[1]), 1) self.__optNewGame.Events.appendEvent(ioEvent3Enum.mouseOut, lambda: self.__changeBoardText(self.__expBoardText[0]), 1) # ---Continue选项绑定事件--- self.__optContinue.Events.appendEvent(ioEvent3Enum.mouseLeftKeyClick, lambda: self.__retSignalIsReadyToEnd(SCENENUM_CONTINUE), 1) self.__optContinue.Events.appendEvent(ioEvent3Enum.mouseIn, lambda: self.__changeBoardText(self.__expBoardText[2]), 1) self.__optContinue.Events.appendEvent(ioEvent3Enum.mouseOut, lambda: self.__changeBoardText(self.__expBoardText[0]), 1) # ---Option选项绑定事件--- self.__optOption.Events.appendEvent(ioEvent3Enum.mouseLeftKeyClick, lambda: self.__retSignalIsReadyToEnd(SCENENUM_OPT), 1) self.__optOption.Events.appendEvent(ioEvent3Enum.mouseIn, lambda: self.__changeBoardText(self.__expBoardText[3]), 1) self.__optOption.Events.appendEvent(ioEvent3Enum.mouseOut, lambda: self.__changeBoardText(self.__expBoardText[0]), 1) # ---Exit选项绑定事件--- self.__optExit.Events.appendEvent(ioEvent3Enum.mouseIn, lambda: self.__changeBoardText(self.__expBoardText[4]), 1) self.__optExit.Events.appendEvent(ioEvent3Enum.mouseOut, lambda: self.__changeBoardText(self.__expBoardText[0]), 1) self.__optExit.Events.appendEvent(ioEvent3Enum.mouseLeftKeyClick, lambda: pygame.event.post(pygame.event.Event(12)), 1) # 渲染参数 self.__step_in = 2 self.__step_out = 5 if self.__frameRate != 0: self.__step_in = 255 / (2 * self.__frameRate) self.__step_out = 255 / (1.5 * self.__frameRate)
def __init__(self, *args): # 初始化场景参数 super().__init__(*args) # resource name self.res_Img1 = 'NG_F_SS_1.bmp' self.res_Img2 = 'NG_F_SS_2.bmp' self.Sound_PourWine = 'NG_F_SS_PW.wav' self.Sound_Cup = 'NG_F_SS_C.wav' self.Sound_Drink = 'NG_F_SS_D.wav' self.Sound_Weak = 'NG_F_SS_W.wav' self.Music_BGM = 'NG_F_SS_BGM.wav' # assets name self.__asf_name1 = 'T_P.assets' self.__asf_name2 = 'T_P_C.assets' # 注册场景 from source.config.AppConfig import registerScene registerScene(SCENENUM_GAME_STARTCG, Prologue_StartCGScene) # 音频 # pygame.mixer.music.load(gl_MusicPath + "TP_F_SS_BGM.mp3") self.res_Sound_PourWine = pygame.mixer.Sound(gl_SoundPath + self.Sound_PourWine) self.res_Sound_PourWine.set_volume(self.config.getVolumeSound()) self.res_Sound_Cup = pygame.mixer.Sound(gl_SoundPath + self.Sound_Cup) self.res_Sound_Cup.set_volume(self.config.getVolumeSound()) self.res_Sound_Drink = pygame.mixer.Sound(gl_SoundPath + self.Sound_Drink) self.res_Sound_Drink.set_volume(self.config.getVolumeSound()) self.res_Sound_Weak = pygame.mixer.Sound(gl_SoundPath + self.Sound_Weak) self.res_Sound_Weak.set_volume(self.config.getVolumeSound()) self.res_Music_BGM = pygame.mixer.Sound(gl_MusicPath + self.Music_BGM) self.res_Music_BGM.set_volume(self.config.getVolumeBGM()) # 其它元素 self.__assetsFile = AssetsFile(os.path.join(gl_AssetsPath, 'PrologueScene')) self.__TextList = self.__assetsFile.decode(self.__asf_name1, AssetsType.SUB) self.__DialogueList = self.__assetsFile.decode(self.__asf_name2, AssetsType.SUB) self.__TextShow = TextElement((200, 460, 270, 18), self.__TextList[0], gl_Font_oth, 16, (255, 255, 255), self.config.getTextAntiAlias()) self.__ImgShow = ImgElement((80, 0, 640, 480), gl_ImgPath + self.res_Img1) self.__DialogueShow = TextElement((0, 500, 430, 18), self.__DialogueList[0], gl_Font_oth, 16, (255, 255, 255), self.config.getTextAntiAlias()) # 注册元素 self.__ElementsList = [] # 设定渲染时的参数 self.__flag_Num = 0 self.__flag_BGMPlayed = False self.now_time, self.interval = None, None self.__TextShow_Interval, self.__DialogueShow_Interval = 5000, 6000 self.__alphaStep_Text, self.__alphaStep_Dia = 0, 0 self.__index, self.__alpha = 0, 0 self.__frameRate = self.config.getFrameRate() if self.__frameRate == 0: self.__alphaStep_Text = self.__TextShow_Interval / 1000 * 0.036 self.__alphaStep_Dia = self.__DialogueShow_Interval / 1000 * 0.416 else: self.__alphaStep_Text = 255 / (((self.__TextShow_Interval - 1500) / 1000) * self.__frameRate) self.__alphaStep_Dia = 255 / self.__frameRate