在andengine Android中向前跳

时间:2012-06-27 11:09:23

标签: android andengine

我正在开发一个精灵必须向前跳的游戏。 我已经探索过它并使用MoveYModifier for up然后MoveYModifier再次向下移动它正常工作,除了在屏幕上多点击一下。但是我想在跳跃的同时向前移动。

                 final Entity playerEntity = move;
                 final float jumpDuration = 3;
                final float startX = playerEntity.getX();
                final float jumpHeight = 100;

                final MoveXModifier moveUpModifier = new MoveXModifier(jumpDuration / 2, startX, startX - jumpHeight); // - since we want the sprite to go up.
                final MoveXModifier moveDownModifier = new MoveXModifier(jumpDuration / 2,startX - jumpHeight, startX);
                final SequenceEntityModifier modifier = new SequenceEntityModifier(moveUpModifier, moveDownModifier);

                playerEntity.registerEntityModifier(modifier);
                return true;

1 个答案:

答案 0 :(得分:2)

为什么不使用MoveModifier而不是使用MoveXModifier? https://github.com/nicolasgramlich/AndEngine/blob/GLES2/src/org/andengine/entity/modifier/MoveModifier.java

final MoveModifier jumpForward = new MoveModifier(pDuration, pFromX, pToX, pFromY, pToY);