1

我有动画平铺精灵。第一次我想动画 4 到 7 帧 4 时间。下一刻我想连续移动 0 到 3 帧。我正在使用这段代码来完成我的工作,但无法完成

playerSprite.animate(new long[] { 100,100,100,100}, 4, 7, 2);
playerSprite.animate(new long[] { 100,100,100,100}, 0, 4, true);
4

1 回答 1

2

根据我的建议,您必须为此目的使用动画侦听器。当第一个动画完成其工作时,您必须开始另一个动画。以下是可以帮助您的代码片段。

animate(new long[] {100,100,100,100}, 4, 7, false, new IAnimationListener() {

        @Override
        public void onAnimationStarted(AnimatedSprite pAnimatedSprite,
                int pInitialLoopCount) {
        }

        @Override
        public void onAnimationLoopFinished(AnimatedSprite pAnimatedSprite,
                int pRemainingLoopCount, int pInitialLoopCount) {
        }

        @Override
        public void onAnimationFrameChanged(AnimatedSprite pAnimatedSprite,
                int pOldFrameIndex, int pNewFrameIndex) {
        }

        @Override
        public void onAnimationFinished(AnimatedSprite pAnimatedSprite) {
            // start your second animation
        }
    });

使用这种方式,您必须在 onAnimationFinished 方法中调用其他动画

于 2013-04-26T17:02:43.623 回答