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