AndEngine AnimatedSprite仅动画第一个精灵

时间:2012-02-19 17:29:52

标签: java android animation sprite andengine

为什么当我添加新的敌人时,没有动画?动画只有第一个敌人..

private BitmapTextureAtlas EnemyTextureAtlas;
private TiledTextureRegion enemyTextureRegion;

EnemyTextureAtlas = new BitmapTextureAtlas(512, 256, TextureOptions.BILINEAR);        
enemyTextureRegion = BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(EnemyTextureAtlas, this, "enemy.png", 400, 0, 2, 2);

private void addEnemy(final float pX, final float pY)
{
    final AnimatedSprite enemy;
    enemy = new AnimatedSprite(pX, pY, this.enemyTextureRegion);
    enemy.animate(200);
    scene.attachChild(enemy);

}

2 个答案:

答案 0 :(得分:3)

enemy = new AnimatedSprite(pX, pY, this.enemyTextureRegion.deepCopy());

而不是

enemy = new AnimatedSprite(pX, pY, this.enemyTextureRegion.clone());

答案 1 :(得分:1)

你需要克隆textureRegion

enemy = new AnimatedSprite(pX, pY, this.enemyTextureRegion.clone());