diff --git a/source/state/level.py b/source/state/level.py index e0b859f..45132ed 100644 --- a/source/state/level.py +++ b/source/state/level.py @@ -60,9 +60,6 @@ class Level(tool.State): self.game_info[c.LITTLEGAME_COMPLETIONS] += 1 self.done = True self.next = c.MAIN_MENU - pg.mixer.music.stop() - pg.mixer.music.load(os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))) ,"resources", "music", "intro.opus")) - pg.mixer.music.play(-1, 0) with open(c.USERDATA_PATH, "w") as f: userdata = {} for i in self.game_info: @@ -554,9 +551,6 @@ class Level(tool.State): self.done = True self.next = c.MAIN_MENU self.persist = {c.CURRENT_TIME:0, c.LEVEL_NUM:self.persist[c.LEVEL_NUM], c.LITTLEGAME_NUM:self.persist[c.LITTLEGAME_NUM]} - pg.mixer.music.stop() - pg.mixer.music.load(os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))) ,"resources", "music", "intro.opus")) - pg.mixer.music.play(-1, 0) # 播放点击音效 pg.mixer.Sound(os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))) ,"resources", "sound", "buttonclick.ogg")).play() diff --git a/source/state/mainmenu.py b/source/state/mainmenu.py index 638c24a..f9c09b4 100644 --- a/source/state/mainmenu.py +++ b/source/state/mainmenu.py @@ -14,6 +14,10 @@ class Menu(tool.State): self.game_info = persist self.setupBackground() self.setupOptions() + self.setupOptionButton() + pg.mixer.music.stop() + pg.mixer.music.load(os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))) ,"resources", "music", "intro.opus")) + pg.mixer.music.play(-1, 0) pg.display.set_caption(c.ORIGINAL_CAPTION) def setupBackground(self): @@ -172,6 +176,7 @@ class Menu(tool.State): # 音量+、音量- + # 在选项菜单打开时,检测是否点击到返回 def checkReturnClick(self, mouse_pos): x, y = mouse_pos if (x >= self.return_button_rect.x and x <= self.return_button_rect.right and diff --git a/source/tool.py b/source/tool.py index f4d2683..78b61ef 100755 --- a/source/tool.py +++ b/source/tool.py @@ -229,8 +229,3 @@ except: GFX = load_all_gfx(os.path.join(os.path.dirname(os.path.dirname(__file__)) ,os.path.join("resources","graphics"))) ZOMBIE_RECT = loadZombieImageRect() PLANT_RECT = loadPlantImageRect() - -# 播放音乐 -pg.mixer.init() -pg.mixer.music.load(os.path.join(os.path.dirname(os.path.dirname(__file__)) ,"resources", "music", "intro.opus")) -pg.mixer.music.play(-1, 0)