I am using AndEngines onSceneTouchEvent method to create a jump affect for a sprite.
The issue i am having is that if the user touches the screen for instance they triple tap the screen the sprite will keep jumping, what i want is for it to receive only 1 click and do one jump for the one touch.
Here is what i am using which is causing this issue.
As you see i try to use a mIsJumping boolean and when the player collides with a invisible rectangle, it is set to false again to allow for jumping again.
@Override
public boolean onSceneTouchEvent(Scene pScene, TouchEvent pSceneTouchEvent) {
if(pSceneTouchEvent.isActionUp()){
if(mIsJumping == false){
SequenceEntityModifier jumpModifier = new SequenceEntityModifier(
new MoveYModifier(.6f, player.getY(), player.getY() - 250, EaseQuadOut.getInstance()),
new MoveYModifier(.6f, player.getY() - 250, player.getY(), EaseBounceOut.getInstance()));
player.registerEntityModifier(jumpModifier);
}
}
return false;
}
From my description above how can i only register one touch even and jump once until the sprite collides with the rectangle?
There’s even an easier solution – use an
IEntityModifierListener.Create the listener this way:
Register it to the
MoveYModifierthat moves the player down. So, when the modifying ends (The jump modification ends),mIsJumpingwill be false. Also, remember to setmIsJumpingtotruewhen the jump starts.