我是 Andengine 的新手,并试图创建一个游戏玩法类似于 River City Ransom - http://www.youtube.com/watch?v=goQlPC5wOic
问题:在创建场景时,我加载了玩家精灵、背景、HUD,并且可以一次性加载它,因为在其他一切准备好之前加载其中任何一个都是没有意义的。
但是当我尝试为新的 Sprite 异步创建一个新的 TiledTextureRegion 时(一个新的敌人从边缘出现在场景中),从资产创建 TextureRegion 时仍然存在延迟。
例子:
new LoadNewEnemyOnSceneTask(enemyTexture, enemyTextureRegion, mScene, this).execute();
public class LoadNewEnemyOnSceneTask extends AsyncTask<String, Void, PixelPerfectAnimatedSprite> {
private PixelPerfectTiledTextureRegion enemyTextureRegion;
private BitmapTextureAtlas enemyTexture;
private Scene scene;
BaseGameActivity act;
public LoadNewEnemyOnSceneTask(BitmapTextureAtlas enemyTexture, PixelPerfectTiledTextureRegion enemyTextureRegion, Scene scene, BaseGameActivity act)
{
this.enemyTexture = enemyTexture;
this.enemyTextureRegion = enemyTextureRegion;
this.scene = scene;
this.act = act;
}
@Override
protected PixelPerfectAnimatedSprite doInBackground(String... params) {
enemyTextureRegion = PixelPerfectTextureRegionFactory.createTiledFromAsset(enemyTexture, act.getAssets(), "akira.png", 0, 200, 5, 3, 0);
PixelPerfectAnimatedSprite enemy = new PixelPerfectAnimatedSprite(480, 200, enemyTextureRegion, act.getVertexBufferObjectManager());
return enemy;
}
@Override
protected void onPostExecute(PixelPerfectAnimatedSprite result)
{
scene.attachChild(result);
}
}
这是内部的 Andengine 错误/功能吗?有没有办法在场景中动态加载新的纹理?我能找到的唯一信息与游戏前资源加载有关。