如何在 Pygame 中制作暂停屏幕?
How to make a pause screen in Pygame?
我想制作一个功能,当我按下 p 时游戏停止并显示 "Game Paused"。
有什么帮助吗?
我建议添加一个 is_paused
布尔标志并在您的 update
方法中添加 if not is_paused
以进行相应操作(update
方法是执行 30 次的方法在你的游戏中每秒):
一些伪代码:
def update(screen, entities, is_paused):
if is_paused:
if is_clicked_button(BUTTON_TO_UNPAUSE):
is_paused = False
return
# Logic on screen, entities and so on...
我想制作一个功能,当我按下 p 时游戏停止并显示 "Game Paused"。
有什么帮助吗?
我建议添加一个 is_paused
布尔标志并在您的 update
方法中添加 if not is_paused
以进行相应操作(update
方法是执行 30 次的方法在你的游戏中每秒):
一些伪代码:
def update(screen, entities, is_paused):
if is_paused:
if is_clicked_button(BUTTON_TO_UNPAUSE):
is_paused = False
return
# Logic on screen, entities and so on...