简体   繁体   中英

LibGDX InputProcessor Documentation

As the documentation on this link suggests

Instead of polling for events, one can process all input events with an InputProcessor.

though then the documentation of InputProcessor says

It will be called each frame before the call to ApplicationListener.render().

As far as I know EventHandlers are called only when the event is fired, thus they are more efficient than polling. 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. So behind the scenes, event listeners queue up all input events. Right before render() any queued events are flushed to your game's 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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