I would like to know if there is a way of using poll()
or get()
without removing the events from the queue.
在我的游戏中,我检查了不同地点(不仅是主要圈子)的投入,有时,我需要在不同地点检查同一事件,而当它从问讯中除去时检查。 我尝试使用<代码>peek(),但问题是,我拿到了与所发生的事件相应的钥匙。
while 1:
event = pygame.event.poll()
if event.type == KEYDOWN:
return event.key
else:
pass
#works but removes event from the queue
这可以取得与活动相应的钥匙,但可使用peek()
。
pygame.event.peek(pygame.KEYDOWN).key
#dosent work
However I can t use the first method because removes the event from the queue so I can t check key events elsewhere in the program.
I don t understand well how the queue
works so maybe I m just mistaking but I tried the first one at different location and only the first time i checked the event it worked.
My goal is to check events in different classes in my game.
感谢您的帮助