|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectJTP.PlayerKeys
public class PlayerKeys
Class for keeping track of which keys a player is holding down. Note: All methods in this class are synchronized.
Field Summary | |
---|---|
static int |
NONE
Constand indicating no key is being held down. |
Constructor Summary | |
---|---|
PlayerKeys()
Create a new PlayerKeys instance. |
Method Summary | |
---|---|
int |
activeKey()
Returns active key. |
void |
clear()
Empties currently held down key cache. |
int |
getAndClearOneOffKey()
Returns the currently set one-off key and clears it. |
boolean |
isRepeating()
Indicates whether the keys are in repeat mode or not. |
boolean |
keyDown(int keyIndex)
Registers a new key as being held down. |
boolean |
keyUp(int keyIndex)
Unregisters key which from 'held down' list. |
boolean |
oneOffKeySet()
Returns whether a one-off key is active. |
void |
setOneOffKey(int keyIndex)
Sets a one-off key. |
void |
setRepeats(boolean on)
Set whether any of the keys are in repeat mode or not. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int NONE
Constructor Detail |
---|
public PlayerKeys()
PlayerKeys
instance.
Method Detail |
---|
public int activeKey()
NONE
if no key is being
held down.public void setOneOffKey(int keyIndex)
keyIndex
- code of one-off key
IllegalArgumentException
- if keyIndex != NONE
.public boolean oneOffKeySet()
true
is a one-off key is set.public int getAndClearOneOffKey()
NONE
).public void setRepeats(boolean on)
on
- flags repeats as on or off.public boolean isRepeating()
true
if repeats are on.public void clear()
public boolean keyDown(int keyIndex) throws IllegalArgumentException
keyIndex
- code of newly pressed key
true
if this is a different key from the current one.
IllegalArgumentException
- if keyIndex < 0
.public boolean keyUp(int keyIndex) throws IllegalArgumentException
keyIndex
- code of key to be released
false
if the key was not previously registered using
keyDown
method.
IllegalArgumentException
- if keyIndex < 0
.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |