Is it generally better to create callbacks for gamepad input, or to handle it in the update() loop?
Hello. Popped into your post now. I do not have much idea about gamepad in Phaser. But I can tell you if your functionality needs to update some values of the scene then you may need to use update
. Adding listeners is done usually in create
.
It must be similar to keyboard event handling. If your one key translates a game object once then you need to do add a listener in create
and respond with changing some coordinate values, x or y. If it is translate the object continuously when you press and hold or upon one press then you need to look for docs if there is a property or function that tells you if a certain key is currently pressed and use that in a condition in update
function to update the desired value so that it happens in every frame. If there is no such function you can even still use a listener in create
and set a flag in handler about it is pressed and in update
use your flag to check if it is pressed, also add another handler to toggle that flag value when the key is released. Like keyboard keydown
keyup
events.