diff --git a/src/scenes/main_menu_scene.py b/src/scenes/main_menu_scene.py index 27675b4..04b8f28 100644 --- a/src/scenes/main_menu_scene.py +++ b/src/scenes/main_menu_scene.py @@ -64,7 +64,7 @@ class MainMenuScene(BaseScene): if event.type == pygame.KEYDOWN: keys = pygame.key.get_pressed() # 获取所有按键状态,用于组合按键判断 if event.key == pygame.K_ESCAPE: - return "exit" # 主循环接收返回,为exit时设置running为False,退出游戏 + self.exit() # 退出游戏 elif keys[pygame.K_z] and keys[pygame.K_x]: # 同时按下Z和X self.button_status = True @@ -122,11 +122,18 @@ class MainMenuScene(BaseScene): text_rect.centerx = screen_rect.centerx # 将文本居中到屏幕 text_rect.y = screen_rect.y + count * 2 * text_rect.height + screen_rect.centerx/2 self.screen.blit(text, text_rect.topleft) - count += 1 # 是否高亮显示 if text_rect.y < self.mouse_pos[1] < text_rect.y + text_rect.height \ and text_rect.x < self.mouse_pos[0] < text_rect.x + text_rect.width: pygame.draw.rect(self.screen, Color.white, text_rect, 1) + # 如果点击鼠标 + if self.mouse_status: + # 点击第一个选项 + if count == 0: + self.switch_to_scene("GameScene") + else: + self.exit() + count += 1 def init_rain(self, max_num):