2013-04-26 97 views
1

我有动画平铺雪碧。第一次我想动画4至7帧4时间。在下一瞬间,我想不断移动0到3帧。我使用此代码做我的工作,但不能完成它AndEngine中的动画平铺雪碧

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

我无法理解“动画4至7架4的时间。”你能否给这个问题添加一些更多的细节? – 2013-04-26 16:54:57

回答

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方法