1

我刚开始使用AndEngine,

我正在移动这样的精灵:

if(pValueY < 0 && !jumping) {

                        jumping = true;

                        // User is currently holding the UP direction
                        // get the player entity (used to apply entity modifier, and get the current X position
                        final Entity playerEntity = (Entity) physicsHandler.getEntity();

                        // set the jump duration, set the starting x position, and how high the jump will be
                        final float jumpDuration = 8;
                        final float startX = playerEntity.getX();
                        final float jumpHeight = 40;

                        // set the move modifiers and set it as a sequence
                        final MoveYModifier moveUpModifier = new MoveYModifier(jumpDuration / 2, startX, startX - jumpHeight); 
                        final MoveYModifier moveDownModifier = new MoveYModifier(jumpDuration / 2, startX + jumpHeight, startX);
                        final SequenceEntityModifier modifier = new SequenceEntityModifier(moveUpModifier, moveDownModifier);

                        // apply modifier
                        playerEntity.registerEntityModifier(modifier);

                    }
                    else {

                        // basically if the user presses left or right this should occur
                        physicsHandler.setVelocityX(pValueX * 10);
                        distance += pValueX;
                    }

我的问题是如何在 registerEntityModifier 函数完成后将跳转设置为 false ?(玩家完成跳跃后)

谢谢!

4

1 回答 1

2

使用andengine的onModifierFinished()方法

    @Override
    protected void onModifierFinished(IEntity pItem)
    {
            super.onModifierFinished(pItem);
            // Your action after finishing modifier
    }

使用此链接了解更多详细信息..,.

于 2012-11-09T18:54:09.813 回答