简体   繁体   English

LibGDX InputProcessor文档

[英]LibGDX InputProcessor Documentation

As the documentation on this link suggests 如此链接上的文档所暗示的

Instead of polling for events, one can process all input events with an InputProcessor. 无需轮询事件,而是可以使用InputProcessor处理所有输入事件。

though then the documentation of InputProcessor says 虽然然后InputProcessor的文档

It will be called each frame before the call to ApplicationListener.render(). 在调用ApplicationListener.render()之前的每一帧都将调用它。

As far as I know EventHandlers are called only when the event is fired, thus they are more efficient than polling. 据我所知,仅在事件触发时才调用EventHandlers,因此它们比轮询更有效。 Why does it say that it is called each frame ? 为什么说它被称为每一帧?

From looking at the source code, I can see that the input processor is called in the game loop right before render() , but only with queued up input events that are aquired from event listeners. 通过查看源代码,我可以看到在render()之前的游戏循环中调用了输入处理器,但仅使用了事件监听器中已排队的输入事件。 So behind the scenes, event listeners queue up all input events. 因此,在后台,事件监听器将所有输入事件排队。 Right before render() any queued events are flushed to your game's InputProcessor. render()之前,所有排队的事件都会刷新到游戏的InputProcessor中。 If there are none, it won't get any calls. 如果没有,它将不会接到任何电话。

I think your quote from the documentation is just trying to tell you at what point in the game lifecycle the input events come through to the processor. 我认为您从文档中引用的内容只是试图告诉您输入事件在游戏生命周期中的什么时候到达处理器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM