S
Stefan Reiter
Hi,
I am working on a little game in J2ME MIDP 2.0.
The player (a sprite) is moving very slowly -
it seems like that it doesn't recognize all buttons that have been
pressed - if I put the thread to sleep for 500 milliseconds,
it does recognize all buttons pressed correctly, but of course
this doesn't speed up the movement of the sprite because
then it always waits half a second for the next move.
That's how my method looks like:
int keyState = getKeyStates();
if ((keyState & LEFT_PRESSED) != 0) {
// This animates the sprite
player.createAnimation(LEFT_PRESSED);
this.movePlayer(LEFT_PRESSED);
}
} else if ((keyState & RIGHT_PRESSED) != 0) {
// This animates the sprite
player.createAnimation(RIGHT_PRESSED);
this.movePlayer(RIGHT_PRESSED);
} else if ((keyState & UP_PRESSED) != 0) {
and so on...
What's wrong here? Any ideas?
Thanks,
Stefan
I am working on a little game in J2ME MIDP 2.0.
The player (a sprite) is moving very slowly -
it seems like that it doesn't recognize all buttons that have been
pressed - if I put the thread to sleep for 500 milliseconds,
it does recognize all buttons pressed correctly, but of course
this doesn't speed up the movement of the sprite because
then it always waits half a second for the next move.
That's how my method looks like:
int keyState = getKeyStates();
if ((keyState & LEFT_PRESSED) != 0) {
// This animates the sprite
player.createAnimation(LEFT_PRESSED);
this.movePlayer(LEFT_PRESSED);
}
} else if ((keyState & RIGHT_PRESSED) != 0) {
// This animates the sprite
player.createAnimation(RIGHT_PRESSED);
this.movePlayer(RIGHT_PRESSED);
} else if ((keyState & UP_PRESSED) != 0) {
and so on...
What's wrong here? Any ideas?
Thanks,
Stefan