[英]Pygame event object
Is it possible to define an event object in pygame? 可以在pygame中定义事件对象吗?
What I am trying to do is loop through all the keyboard events in a method, I then want to call that method with an event as a parameter, but I first need to define it. 我想做的是遍历方法中的所有键盘事件,然后我想以事件作为参数来调用该方法,但是我首先需要对其进行定义。 Is this possible?
这可能吗?
Im using Pygame 3.3 and python 3. 我正在使用Pygame 3.3和python 3。
An event can be made with the command pygame.event.Event(type, dict)
. 可以使用
pygame.event.Event(type, dict)
命令pygame.event.Event(type, dict)
一个事件。 The type will be what you want it to return when the event.type()
command is used on it. 类型将是您要在其上使用
event.type()
命令时返回的类型。 The dict will include every other attribute. 该字典将包含所有其他属性。
An example: pygame.event.Event(pygame.MOUSEBUTTONDOWN, {'button':1})
would return a MOUSEBUTTONDOWN
event with an attribute button
of 1. 例如:
pygame.event.Event(pygame.MOUSEBUTTONDOWN, {'button':1})
将返回一个MOUSEBUTTONDOWN
事件,其属性button
为1。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.