为什么当我添加新敌人时却没有动画?只为第一个敌人制作动画。

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);

}

最佳答案

您需要克隆textureRegion

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

07-28 03:55