|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--nankin.zheng.gatem.controller.GameInputEvent
GameInputEvent contains user input (key or mouse) information.
It is created by KeyController or MouseController, and passed to Controller, and then passed to GameInputEventListener objects that cares about user inputs.
NOTE that if it is created by KeyController, it contains keyboard input information only. And if it is created by MouseController, it contains mouse input information only.
Field Summary | |
static int |
A_KEY
|
static int |
B_KEY
|
static int |
C_KEY
|
static int |
D_KEY
|
static int |
DOWN_KEY
|
static int |
E_KEY
|
static int |
F_KEY
|
private static int |
FLAG_NUM
|
private boolean[] |
flags
|
private static int |
KEY_FLAG_NUM
|
private boolean |
keyInformation
|
static int |
LEFT_CLICK
|
static int |
LEFT_KEY
|
static int |
MIDDLE_CLICK
|
static int |
MOUSE_POSITION
|
static int |
PAUSE_KEY
|
private Position |
position
|
static int |
RIGHT_CLICK
|
static int |
RIGHT_KEY
|
static int |
SELECT_KEY
|
static int |
START_KEY
|
static int |
UP_KEY
|
Constructor Summary | |
GameInputEvent()
Constructor. |
Method Summary | |
void |
copy(GameInputEvent ievt)
Copy both key information and mouse information of ievt to itself. |
void |
copyKeyPart(GameInputEvent ievt)
Copy the key information part of ievt to itself. |
void |
copyMousePart(GameInputEvent ievt)
Copy the mouse information part of ievt to itself. |
int |
getDirection()
Get the direction, which is indicated by user keyboard input. |
Position |
getPosition()
Get the position where mouse is clicking. |
boolean |
isKeyInformation()
Which kind of information does this event contain. |
boolean |
isPressing(int button)
Query whether a key or a mouse button is pressed. |
void |
setFlag(int index)
Set a flag by its index, which means that a corresponding key or mouse button is pressed. |
void |
setKeyInformation(boolean b)
Set its information kind. |
void |
setPosition(Position pos)
Set the position where mouse is clicking. |
void |
unsetFlag(int index)
Unset a flag by its index, which means that a corresponding key or mouse button is released. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int LEFT_KEY
public static final int RIGHT_KEY
public static final int UP_KEY
public static final int DOWN_KEY
public static final int A_KEY
public static final int B_KEY
public static final int C_KEY
public static final int D_KEY
public static final int E_KEY
public static final int F_KEY
public static final int SELECT_KEY
public static final int START_KEY
public static final int PAUSE_KEY
public static final int LEFT_CLICK
public static final int RIGHT_CLICK
public static final int MIDDLE_CLICK
public static final int MOUSE_POSITION
private static final int FLAG_NUM
private static final int KEY_FLAG_NUM
private boolean keyInformation
private boolean[] flags
private Position position
Constructor Detail |
public GameInputEvent()
Method Detail |
public boolean isKeyInformation()
public void setKeyInformation(boolean b)
b
- true if it contains only key info.
false if it contains only mouse info.public void setFlag(int index)
This method is called by Controller.
index
- flag index.public void unsetFlag(int index)
This method is called by Controller.
index
- flag index.public void copy(GameInputEvent ievt)
ievt
- GameInputEvent to be copied.public void copyKeyPart(GameInputEvent ievt)
ievt
- GameInputEvent to be copied.public void copyMousePart(GameInputEvent ievt)
ievt
- GameInputEvent to be copied.public void setPosition(Position pos)
This method is called by MouseController.
pos
- position where mouse is clicking.public boolean isPressing(int button)
button
- button index
public int getDirection()
public Position getPosition()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |