AndEngine AnimatedSprite 仅对第一个精灵进行动画处理
为什么当我添加新敌人时,它没有动画?动画只有第一个敌人..
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);
}
Why when I am add the new enemy, that don't animate? Animated only first enemy..
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);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
enemy = new AnimatedSprite(pX, pY, this.enemyTextureRegion.deepCopy());
而不是
enemy = new AnimatedSprite(pX, pY, this.enemyTextureRegion.clone());
代码>enemy = new AnimatedSprite(pX, pY, this.enemyTextureRegion.deepCopy());
instead of
enemy = new AnimatedSprite(pX, pY, this.enemyTextureRegion.clone());
您需要克隆textureRegion
You need to clone textureRegion