I am making a simple american football game, and I'm having an issue with the onSceneTouchEvent function, I have this code:
public boolean onSceneTouchEvent(final Scene pScene, final TouchEvent pSceneTouchEvent) {
if (hiking == 0) {
Log.v("me", "Only the player should move");
return hike();
} else {
Log.v("me", "this shouldn't ever happen on first click");
return throwBall(pSceneTouchEvent);
}
}
Inside hike() I set hiking to 1, so that theoretically, the player should be able to click anywhere to hike the ball, (all the other sprites start moving and the ball is not thrown). Then on the second click the ball is thrown. But with one click on the emulator, the ball is hiked and thrown at the same time, I also see this in the log (after only one click):
12-21 14:34:32.113: V/me(1189): Only the player should move
12-21 14:34:32.143: V/me(1189): this shouldn't ever happen on first click
12-21 14:34:32.183: V/me(1189): this shouldn't ever happen on first click
So it appears that it's triggering three times on one click? Why is this happening? How can I make it only run the code once per click?
Update:
Perhaps I could just prevent any events by using a timer? Like disable the listener for a second after the hike? I'm hoping there is a better solution though.