pygame中可能有“for pygame.event.get()中的事件:”多次在同一个循环中,还是只能使用一次?我正在学习pygame,并且我决定定义两个函数来检查事件,但是当一个被调用时,另一个不起作用。请记住,我是一个noob。这显然不是实际的代码,但它是我正在做的事情。多次检查pygame事件
import pygame
class someclass:
def __init__(self):
some declaration
def somefunction(self):
for event in pygame.event.get():
if event.type == someevent:
some code
def mainloop(self):
someinstance = somesubclass()
while True:
someinstance.somefunction2()
self.somefunction()
class somesubclass:
def __init__(self):
some declaration
def somefunction2(self):
for event in pygame.event.get():
if event.type == someevent
somecode
maininstance = someclass()
maininstance.mainloop()
somefunction不执行
最好只有一个。你应该发布一些代码,所以我们可以帮助你。 – jgritty
在你的例子中使用真实的代码。也许问题不在于“建设”,而在于一些真正的指导。 – furas
我在你的例子中加了一些'print',我看到'somefunction()'被执行。我没有测试事件。 – furas