All examples · Input · As Markdown, for AIs

Pointer pressed, held, released

What this example shows

usePointer() can be asked from an update the same way as the keyboard. justPressed() is true for the one frame a finger or a button goes down, so a click fires one shot however long it is held. isDown() is true for as long as it is held, and here charges the ring around the cannon. justReleased() is true for the frame it comes up: letting go of a full charge fires a big shot.

With a button, only that one: justPressed('right') is the right button, and changes the colour of the shots. 'main' is the left button or a finger, and left out it is any; every name is in INPUT.POINTER_BUTTONS. None of them says what was pressed: for that there are onDown and its target, or isPressing(sprite). Click to shoot, hold to charge, right click to change colour.

Starting
Starting
—