如何关闭 pyglet window?
How to close a pyglet window?
我有以下问题。
假设我有以下代码:
@window.event
def on_key_press( symbol, mod):
if condition == True:
return print("Game over")
pyglet.app.run()
我还需要在满足条件 == True 后关闭 window。请问我该怎么做?
我试过了:
@window.event
def on_key_press( symbol, mod):
if condition == True:
return print("Game over")
pyglet.app.exit()
但是没有用。非常感谢您的帮助!
函数在控制流中第一次出现 return
时终止。您必须删除 return
语句。
@window.event
def on_key_press( symbol, mod):
if condition == True:
# return print("Game over") <--- DELETE
print("Game over")
pyglet.app.exit()
我有以下问题。 假设我有以下代码:
@window.event
def on_key_press( symbol, mod):
if condition == True:
return print("Game over")
pyglet.app.run()
我还需要在满足条件 == True 后关闭 window。请问我该怎么做? 我试过了:
@window.event
def on_key_press( symbol, mod):
if condition == True:
return print("Game over")
pyglet.app.exit()
但是没有用。非常感谢您的帮助!
函数在控制流中第一次出现 return
时终止。您必须删除 return
语句。
@window.event
def on_key_press( symbol, mod):
if condition == True:
# return print("Game over") <--- DELETE
print("Game over")
pyglet.app.exit()