Hy, I have started a Game in andengine for android, I want to apply a jump functionality on a sprite which will be like some projectile motion , up and forward as well . I have applied move modifier to gain that functionality. But that is not in projectile motion.
How can i achieve that and while the jump of my sprite by tapping again it cant jump again until it completes it jump.i dont want to use delay function on scene touch .any help .
final Entity playerEntity = move;
final float jumpDuration = 1;
final float startX = playerEntity.getX();
final float jumpHeight = 60;
move.getTextureRegion().setFlippedVertical(true);
final MoveModifier jumpForwardUp = new MoveModifier(jumpDuration/2, startX, startX - jumpHeight, playerEntity.getY(), playerEntity.getY() + 130);
final MoveModifier jumpForwardDown = new MoveModifier(jumpDuration/2, startX - jumpHeight, startX, playerEntity.getY() + 130, playerEntity.getY() + 170);
final SequenceEntityModifier modifier = new SequenceEntityModifier(jumpForwardUp ,jumpForwardDown);
playerEntity.registerEntityModifier(modifier);
Try using
JumpModifierand for some real physics work, go forBox2d ExtensionofAndEngineand go through some ofAndEngineexamples code.Edit:
AndEnginehave list of modifiers.JumpModifieris one of them. Maintain a class level or project levelflagthat istruewhen your object is in jump and isfalsewhen object is in normal state.Every modifier takes an object of
IModifierListnerset thatflagtotrueinonStartofIModifierListnerand set that tofalseatonEndofIModifierListner. at every tap check if thatflagistruethen simplereturnand do nothing.