0

我正在开发一个精灵必须向前跳跃的游戏。我已经探索过它并使用 MoveYModifier 向上,然后 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;
4

1 回答 1

2

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

final MoveModifier jumpForward = new MoveModifier(pDuration, pFromX, pToX, pFromY, pToY);
于 2012-06-27T11:20:43.703 回答