Вы не инициализировали mMainScene.Вы не можете ссылаться (т. Е. Присоединять методы Children / call, пока не определите, что такое mMainScene.)
Не могли бы вы проверить, имеет ли значение mMainScene значение null, или перенести свое назначение mMainScene в onLoadResources ()?
Можете ли вы переместить определение mMainScene из onLoadScene в onLoadResources?
public void onLoadResources() {
this.mBitmapTextureAtlas = new BitmapTextureAtlas(512, 512,
TextureOptions.BILINEAR_PREMULTIPLYALPHA);
BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");
this.mPlayerTextureRegion = BitmapTextureAtlasTextureRegionFactory
.createFromAsset(this.mBitmapTextureAtlas, this, "Player.png",
0, 0);
this.mEngine.getTextureManager().loadTexture(this.mBitmapTextureAtlas);
final int PlayerX = (int)(mCamera.getWidth() / 2);
final int PlayerY = (int) ((mCamera.getHeight() - mPlayerTextureRegion
.getHeight()) / 2);
this.player = new Sprite(PlayerX, PlayerY, this.mPlayerTextureRegion);
this.player.setScale(2);
this.mMainScene = new Scene();
this.mMainScene.setBackground(new ColorBackground(0.09804f, 0.6274f, 0.8784f));
this.mMainScene.attachChild(this.player);
}
public Scene onLoadScene() {
return mMainScene;
}
Редактировать:
Основываясь на примере Snake , кажется, что вы должны добавить детей всцена в методе onLoadScene:
public Scene onLoadScene() {
this.mEngine.registerUpdateHandler(new FPSLogger());
this.mScene = new Scene();
for(int i = 0; i < LAYER_COUNT; i++) {
this.mScene.attachChild(new Entity());
}