Class Input
java.lang.Object
com.codename1.gaming.platformer.Input
The buttons an actor reads, as bits of one int per tick.
A tick's input is a single int, which is what makes a run cheap to record
(InputLog) and exact to replay. Touch controls, a keyboard and a gamepad all
produce the same bits, so the simulation never knows which one a player used.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intActivate what the actor stands at: a lever, a door, a sign.static final intEvery defined bit.static final intUse the jetpack or glide while held (an ability decides which).static final intDash.static final intDown: crouch, climb down, drop through a one-way platform withJUMP.static final intUse the weapon.static final intJump.static final intMove left.static final intMove right.static final intRun while held.static final intUp: climb, look up, enter a door. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanheld(int bits, int button) Whether a button is held this tick.static inthorizontal(int bits) The horizontal direction held.static booleanpressed(int bits, int previous, int button) Whether a button went down this tick.static intvertical(int bits) The vertical direction held.
-
Field Details
-
LEFT
public static final int LEFTMove left.- See Also:
-
RIGHT
public static final int RIGHTMove right.- See Also:
-
UP
public static final int UPUp: climb, look up, enter a door.- See Also:
-
DOWN
public static final int DOWNDown: crouch, climb down, drop through a one-way platform withJUMP.- See Also:
-
JUMP
public static final int JUMPJump.- See Also:
-
RUN
public static final int RUNRun while held.- See Also:
-
DASH
public static final int DASHDash.- See Also:
-
FIRE
public static final int FIREUse the weapon.- See Also:
-
ACTIVATE
public static final int ACTIVATEActivate what the actor stands at: a lever, a door, a sign.- See Also:
-
ALT
public static final int ALTUse the jetpack or glide while held (an ability decides which).- See Also:
-
ALL
public static final int ALLEvery defined bit.- See Also:
-
-
Method Details
-
held
public static boolean held(int bits, int button) Whether a button is held this tick.
Parameters
bits: this tick's inputbutton: one of the button constants
Returns
true while held
-
pressed
public static boolean pressed(int bits, int previous, int button) Whether a button went down this tick.
Parameters
bits: this tick's inputprevious: the previous tick's inputbutton: one of the button constants
Returns
true on the press edge
-
horizontal
public static int horizontal(int bits) The horizontal direction held.
Parameters
bits: this tick's input
Returns
-1 for left, 1 for right, 0 for neither or both
-
vertical
public static int vertical(int bits) The vertical direction held.
Parameters
bits: this tick's input
Returns
-1 for up, 1 for down, 0 for neither or both
-