|
GTGE API | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface BaseInput
BaseInput interface provides all needed functions for polling
keyboard and mouse input.
Common methods of how-to-use BaseInput:
public class InputEngine implements BaseInput {
.....
public static void main(String[] args) {
BaseInput engine = new InputEngine(...);
engine.refresh();
// game loop
long elapsedTime = 0;
while (true) {
// update input
engine.update(elapsedTime);
// poll input
engine.isKeyXXX(KeyEvent.XXX);
engine.isMouseXXX(MouseEvent.XXX);
}
// clean up input engine
engine.cleanup();
}
}
| Field Summary | |
|---|---|
static int |
NO_BUTTON
Indicates no mouse button is being pressed. |
static int |
NO_KEY
Indicates no key is being pressed. |
| Method Summary | |
|---|---|
void |
cleanup()
Releases any system resources hooked by this input engine. |
int |
getKeyPressed()
Returns key pressed or NO_KEY if no key is being pressed. |
int |
getKeyReleased()
Returns key released or NO_KEY if no key is being released. |
int |
getMouseDX()
Returns the delta of mouse x-coordinate. |
int |
getMouseDY()
Returns the delta of mouse y-coordinate. |
int |
getMousePressed()
Returns mouse button pressed or NO_BUTTON if no button is being
pressed. |
int |
getMouseReleased()
Returns mouse button released or NO_BUTTON if no button is being
released. |
int |
getMouseX()
Returns the mouse x-coordinate. |
int |
getMouseY()
Returns the mouse y-coordinate. |
boolean |
isKeyDown(int keyCode)
Returns true if the specified key is being pressed. |
boolean |
isKeyPressed(int keyCode)
Returns true if the specified key is being pressed. |
boolean |
isKeyReleased(int keyCode)
Returns true if the specified key is being released. |
boolean |
isMouseDown(int button)
Returns true if the specified button is being pressed. |
boolean |
isMouseExists()
Returns true, if the mouse pointer is in input component area. |
boolean |
isMousePressed(int button)
Returns true if the specified button is being pressed. |
boolean |
isMouseReleased(int button)
Returns true if the specified button is being released. |
boolean |
isMouseVisible()
Returns mouse pointer visible status. |
void |
mouseMove(int x,
int y)
Move the mouse to x, y screen coordinate. |
void |
refresh()
Refresh all input actions to empty. |
void |
setMouseVisible(boolean visible)
Sets mouse pointer visible status. |
void |
update(long elapsedTime)
Updates input engine actions, this method need to be called in tight loop. |
| Field Detail |
|---|
static final int NO_BUTTON
static final int NO_KEY
| Method Detail |
|---|
void update(long elapsedTime)
void refresh()
void cleanup()
void mouseMove(int x,
int y)
x, y screen coordinate.
x - the x-coordinate of the new mouse locationy - the y-coordinate of the new mouse locationboolean isMouseExists()
int getMouseX()
x-coordinate.
int getMouseY()
y-coordinate.
int getMouseDX()
x-coordinate.
int getMouseDY()
y-coordinate.
int getMouseReleased()
NO_BUTTON if no button is being
released.
MouseEvent.BUTTON1,
MouseEvent.BUTTON2,
MouseEvent.BUTTON3boolean isMouseReleased(int button)
button - the mouse button to be checked
MouseEvent.BUTTON1,
MouseEvent.BUTTON2,
MouseEvent.BUTTON3int getMousePressed()
NO_BUTTON if no button is being
pressed.
MouseEvent.BUTTON1,
MouseEvent.BUTTON2,
MouseEvent.BUTTON3boolean isMousePressed(int button)
button - the mouse button to be checked
MouseEvent.BUTTON1,
MouseEvent.BUTTON2,
MouseEvent.BUTTON3boolean isMouseDown(int button)
button - the mouse button to be checked
MouseEvent.BUTTON1,
MouseEvent.BUTTON2,
MouseEvent.BUTTON3int getKeyReleased()
NO_KEY if no key is being released.
KeyEvent.VK_1boolean isKeyReleased(int keyCode)
keyCode - the key to be checked
KeyEvent.VK_1int getKeyPressed()
NO_KEY if no key is being pressed.
KeyEvent.VK_1boolean isKeyPressed(int keyCode)
keyCode - the key to be checked
KeyEvent.VK_1boolean isKeyDown(int keyCode)
keyCode - the key to be checked
KeyEvent.VK_1void setMouseVisible(boolean visible)
visible - mouse pointer visible statusboolean isMouseVisible()
|
GTGE API | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||