修改退出判断方式:下一场景名称为“game_exit”时退出游戏

This commit is contained in:
chicrobot committed 2026-07-30 02:03:01 +08:00
1 parent 1ff35871dc
commit 887bef6035
2 files changed
+11 -4

No files matched your search

+4 -3
View File
@@ -32,9 +32,7 @@ class Game:
for event in pygame.event.get(): # 这里已经获取了事件,事件队列被清空,在场景的update中再次获取将没有事件
if event.type == pygame.QUIT:
self.running = False
result = self.scene.handle_event(event) # 当前场景接收事件
if result == "exit":
self.running = False
self.scene.handle_event(event) # 当前场景接收事件
# 检查是否切换场景
if self.scene.next_scene is not None:
@@ -47,6 +45,9 @@ class Game:
# 场景每帧更新逻辑运行
self.scene.update()
# 当场景的下一场景为game_exit时退出游戏
if self.scene.next_scene == "game_exit":
self.running = False
# 更新显示
pygame.display.update()