0

有人知道如何从特定索引(在我的情况下从当前索引)为精灵设置动画吗?我尝试了一些东西但没有成功-

    if (!sprite.isAnimationRunning()) {
     int index = sprite.getCurrentTileIndex();
     sprite.animate(frameDurations, index, 7, true);
    }

每次我有一个例外,因为 frameDurations 不等于 frameCount。我只想在按下按钮时从 currentIndex 为精灵设置动画。:/

4

2 回答 2

0

这个精灵有 8 帧。我正在尝试为第 7 帧和第 8 帧设置动画。一旦完成,我将从第 0 帧动画到第 6 帧,其中 100 是持续时间

Player.sprite.animate(
                                            new long[] { 100, 100 }, 7, 8,
                                            false, new IAnimationListener() {

                                                public void onAnimationStarted(
                                                        AnimatedSprite pAnimatedSprite,
                                                        int pInitialLoopCount) {

                                                }

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

                                                }

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

                                                }

                                                public void onAnimationFinished(
                                                        AnimatedSprite pAnimatedSprite) {
                                                    Player.sprite.animate(
                                                            new long[] { 100,
                                                                    100, 100,
                                                                    100, 100,
                                                                    100, 100 },
                                                            0, 6, true);
                                            }
                                        });
于 2013-11-30T05:51:38.353 回答
0
sprite.animate(new long[]{}, "your current index", "your last index", loop );

Use this function to animate sprite from specific index to your last index. add how many number of 
frames time to animate that from current index to last index . and loop is `boolean varible` that    signifies animate once or `repeate`.
于 2013-10-26T04:53:45.007 回答