我为gamecene添加了autoparallax代码,我的游戏有效,但背景显示黑屏,请帮助我,提前谢谢你。 在resourcemanager.java中
private void loadGameGraphics() {
BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/game/");
mAutoParallaxBackgroundTexture = new BitmapTextureAtlas(activity.getTextureManager(), 1024, 1024,TextureOptions.BILINEAR);
mParallaxLayerFront = BitmapTextureAtlasTextureRegionFactory.createFromAsset( mAutoParallaxBackgroundTexture, activity, "parallax_background_layer_front.png", 0, 0);
mParallaxLayerBack = BitmapTextureAtlasTextureRegionFactory.createFromAsset( mAutoParallaxBackgroundTexture, activity, "parallax_background_layer_back.png", 0, 188);
mParallaxLayerMid = BitmapTextureAtlasTextureRegionFactory.createFromAsset( mAutoParallaxBackgroundTexture, activity, "parallax_background_layer_mid.png", 0, 669);
}
在gamescene.java中
私有场景createBackground() {
resourcesManager.mAutoParallaxBackgroundTexture.load();
final Scene scene = new Scene();
final AutoParallaxBackground autoParallaxBackground = new AutoParallaxBackground(0, 0, 0, 5);
int CAMERA_HEIGHT = 480;
autoParallaxBackground.attachParallaxEntity(new ParallaxEntity(0.0f, new Sprite(0, CAMERA_HEIGHT - resourcesManager.mParallaxLayerBack.getHeight(), resourcesManager.mParallaxLayerBack,vbom)));
autoParallaxBackground.attachParallaxEntity(new ParallaxEntity(-5.0f, new Sprite(0, 80, resourcesManager.mParallaxLayerMid, vbom)));
autoParallaxBackground.attachParallaxEntity(new ParallaxEntity(-10.0f, new Sprite(0, CAMERA_HEIGHT - resourcesManager.mParallaxLayerFront.getHeight(), resourcesManager.mParallaxLayerFront, vbom)));
scene.setBackground(autoParallaxBackground);
return scene;
}
栈跟踪
02-19 05:01:55.710:W / AndEngine(1083):ParallaxEntity的OffsetCenterXposition预计为0。 02-19 05:01:55.710:W / AndEngine(1083):ParallaxEntity的OffsetCenterXposition预计为0。 02-19 05:01:55.710:W / AndEngine(1083):ParallaxEntity的OffsetCenterXposition预计为0。
答案 0 :(得分:0)
移动此行
resourcesManager.mAutoParallaxBackgroundTexture.load();
从createBackground()到loadGameGraphics()。