2011-11-24 48 views
3

我試圖讓動畫只有一次,但它是動畫兩次任何人都可以幫助我?以下是代碼動畫雪碧在AndEngine中動畫更多一次

CuttingLineEffect(float x, float y, TiledTextureRegion line_region) 
{ 
    super(x, y, line_region); 
    this.animate(60, 1); 
    this.mPhysicsHandler = new PhysicsHandler(this); 
    this.registerUpdateHandler(this.mPhysicsHandler); 
    this.setPosition(x-this.getWidth()/2-50+this.getWidth()/2,y+50); 
} 

@Override 
protected void onManagedUpdate(float pSecondsElapsed) { 

    if(!set) 
    { 
     MainMenu.LineList.add(this); 
     set = true; 
    } 
    if(!this.isAnimationRunning() && !time_to_unload) 
    { 
     time_to_unload = true; 

    } 


    super.onManagedUpdate(pSecondsElapsed); 
}; 

回答

3

Animate()第二個參數是要循環動畫的次數。因爲只有在你可以使用的時候你纔想要動畫。

this.animate(60,0); 
+0

但這不會動畫,因爲它一旦它動畫的精靈的生命時間 –

+0

嗯..對不起,這this.animate呢(60,假); ? – Rohan

+0

這根本不動畫:( –

3
Sprite.animate(100,false); 
  • 100 - >的持續時間對於每個幀
  • false - >所述第二參數是要循環或沒有。
+0

謝謝...我通過使用x.animate(100,0 ); –