Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在Pygame中创建暂停屏幕?_Python_Pygame - Fatal编程技术网

Python 如何在Pygame中创建暂停屏幕?

Python 如何在Pygame中创建暂停屏幕?,python,pygame,Python,Pygame,我想做一个功能,当我按下p键时,游戏停止并显示“游戏暂停” 有什么帮助吗?我建议在更新方法中添加一个暂停布尔标志,如果没有暂停,则添加更新方法以采取相应的行动(更新方法是在游戏中每秒执行30次的方法): 一些伪代码: def update(screen, entities, is_paused): if is_paused: if is_clicked_button(BUTTON_TO_UNPAUSE): is_paused = False

我想做一个功能,当我按下p键时,游戏停止并显示“游戏暂停”


有什么帮助吗?

我建议在
更新
方法中添加一个
暂停
布尔标志,如果没有暂停,则添加
更新
方法以采取相应的行动(更新方法是在游戏中每秒执行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...