2013-05-11 113 views
0

我在畫布上有多個對象。在一定條件之後,我想讓我的一些精靈做動畫。這裏我的代碼:在Android上使用andengine動畫特定精靈與多個精靈

private AnimatedSprite[] sign; 
sign = new AnimatedSprite[9]; 
// some loop code to create 9 sign 
.. 
sign[index] = new AnimatedSprite(x, y, myregion); 
.. 

直到這部分是好的,所有的跡象是在位。但是當我想爲某個精靈製作動畫時,所有這個精靈都會做動畫。這裏的代碼:

while(signIndex<9) 
{ 
    if(signIndex==winSlot[0] || signIndex==winSlot[1] || signIndex==winSlot[2]) 
    { 
    grupSign= null; 
    grupSign= sign[signIndex]; 
    grupSign.animate(200, true); 
    } 
    signIndex++; 
} 

任何人都知道,並可以幫助我如何使只有特定的精靈做動畫?

回答

1

根據我的建議,您必須在創建動畫sprite對象時使用deepCopy()方法。根據以下內容

sign[index] = new AnimatedSprite(x, y, myregion.deepCopy()); 

使用deepCopy()方法的優點是每次都會爲您的精靈創建新區域。