2013-10-22 28 views
0

有沒有人知道如何從特定索引(在我的情況下,從當前索引)爲精靈製作動畫?我嘗試一些但沒有成功 -如何從特定索引設置animatedSprite的動畫效果? - andengine

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

並且每次我有一個異常,因爲frameDurations不等於frameCount。我只是想按下按鈕時從currentIndex動畫精靈。 :/

回答

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`. 
+0

我寫動畫的第7和第8幀這在我的問題中,但它不工作,就像那樣..因爲當前索引每次都在變化,當索引被改變時,「new long [] {}」應該是不同的。在我的情況下,我發現這個long [] frameDuration與「for循環」,但我不知道這是否是這樣做的好方法。不管怎麼說,還是要謝謝你 :) – Shefchenko

0

此子畫面有8個frames.Im嘗試。一旦這個過程完成之後,我會從第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); 
              } 
             }); 
相關問題