com.brackeen.javagamebook.input
Class GameAction

java.lang.Object
  extended bycom.brackeen.javagamebook.input.GameAction

public class GameAction
extends java.lang.Object

The GameAction class is an abstract to a user-initiated action, like jumping or moving. GameActions can be mapped to keys or the mouse with the InputManager.


Field Summary
static int DETECT_INITAL_PRESS_ONLY
          Initial press behavior.
static int NORMAL
          Normal behavior.
 
Constructor Summary
GameAction(java.lang.String name)
          Create a new GameAction with the NORMAL behavior.
GameAction(java.lang.String name, int behavior)
          Create a new GameAction with the specified behavior.
 
Method Summary
 int getAmount()
          For keys, this is the number of times the key was pressed since it was last checked.
 java.lang.String getName()
          Gets the name of this GameAction.
 boolean isPressed()
          Returns whether the key was pressed or not since last checked.
 void press()
          Signals that the key was pressed.
 void press(int amount)
          Signals that the key was pressed a specified number of times, or that the mouse move a spcified distance.
 void release()
          Signals that the key was released
 void reset()
          Resets this GameAction so that it appears like it hasn't been pressed.
 void tap()
          Taps this GameAction.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NORMAL

public static final int NORMAL
Normal behavior. The isPressed() method returns true as long as the key is held down.

See Also:
Constant Field Values

DETECT_INITAL_PRESS_ONLY

public static final int DETECT_INITAL_PRESS_ONLY
Initial press behavior. The isPressed() method returns true only after the key is first pressed, and not again until the key is released and pressed again.

See Also:
Constant Field Values
Constructor Detail

GameAction

public GameAction(java.lang.String name)
Create a new GameAction with the NORMAL behavior.


GameAction

public GameAction(java.lang.String name,
                  int behavior)
Create a new GameAction with the specified behavior.

Method Detail

getName

public java.lang.String getName()
Gets the name of this GameAction.


reset

public void reset()
Resets this GameAction so that it appears like it hasn't been pressed.


tap

public void tap()
Taps this GameAction. Same as calling press() followed by release().


press

public void press()
Signals that the key was pressed.


press

public void press(int amount)
Signals that the key was pressed a specified number of times, or that the mouse move a spcified distance.


release

public void release()
Signals that the key was released


isPressed

public boolean isPressed()
Returns whether the key was pressed or not since last checked.


getAmount

public int getAmount()
For keys, this is the number of times the key was pressed since it was last checked. For mouse movement, this is the distance moved.