小编mou*_*123的帖子

pygame.quit() 可靠吗?

我最近制作了一个小游戏,然后使用pyinstaller. 运行时,有两种方法可以关闭它。它是全屏的,所以不包括点击红色的 x 按钮,但基本上我有这个

if keys[pygame.K_ESCAPE]:
    pygame.quit()
Run Code Online (Sandbox Code Playgroud)

和这个

if exit_button.colliderect(cursor_rect) and click==1:
    pygame.quit()
Run Code Online (Sandbox Code Playgroud)

单击退出按钮后,游戏将毫无问题地关闭。光标紧接着在短时间内显示小加载符号。但是,当按下转义键时,窗口会关闭,但会弹出一条消息,“无法执行脚本”。我在 Windows 10 上,游戏是在 pycharm 上用 pygame 制作的,而 exe 是用pyinstaller --onefile -w game.py.

也许这是代码中的一个错误,但它在 IDE 中运行良好,我没有做任何不同的事情。我还可以确认它没有丢失图像或媒体。谢谢。

python pygame exe runtime-error pyinstaller

2
推荐指数
1
解决办法
111
查看次数

标签 统计

exe ×1

pygame ×1

pyinstaller ×1

python ×1

runtime-error ×1