Gam*_*ids 5 java android andengine andengine-gles-2
我正在使用AndEngine GLES 2为Android编写游戏.一切都工作正常 - 我有一个背景图像,有精灵移动甚至一些音乐 - 直到最近我尝试了一些新的东西(我希望能够在两个不同的场景之间切换)当显示变黑.
我仍然可以执行游戏并且没有显示错误.我在游戏过程中显示的所有日志条目都显示出来,即使音乐正在播放,所以我知道游戏"正常"运行,但我看不到任何图像.没有.全黑.
所以我想,在出现这个"错误"之前将一切都改回来,就可以了.但屏幕仍然是黑色的.
我甚至尝试评论所有内容,但背景图片 - 没有.
现在,如果问的不是太多,请问任何人都可以查看这段简短的代码并告诉我那里有什么问题?
这是我使用的变量:
private SmoothCamera camera;
private BitmapTextureAtlas bitmapTextureAtlas;
private Scene scene;
private Sprite background;
Run Code Online (Sandbox Code Playgroud)
该EngineOptions我从来没有改变过,所以他们应该是好的.
@Override
public EngineOptions onCreateEngineOptions() {
float positionX = 80f; // horizontal (x) position of the camera
float positionY = 280f; // vertical (y) position of the camera
float velocityX = 200f; // velocity of the horizontal camera movement
float velocityY = 200f; // velocity of the vertical camera movement
float zoomFactor = 1f; // the camera's zoom Factor (standard := 1)
this.camera = new SmoothCamera(positionX, positionY, this.getWindowManager().getDefaultDisplay().getWidth(), this.getWindowManager().getDefaultDisplay().getHeight(), velocityX, velocityY, zoomFactor);
EngineOptions options = new EngineOptions(true, ScreenOrientation.LANDSCAPE_SENSOR, new RatioResolutionPolicy(this.camera.getWidth(), this.camera.getHeight()), this.camera);
return options;
}
Run Code Online (Sandbox Code Playgroud)
在这里,我创建TextureAtlas并加载背景图像.
@Override
protected void onCreateResources() {
// create the TextureAtlas
BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");
this.bitmapTextureAtlas = new BitmapTextureAtlas(this.getTextureManager(), 1024, 1600, TextureOptions.NEAREST);
// background
this.background = new Sprite(0, 0, BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(this.bitmapTextureAtlas, this, "background.png", 0, 0, 1, 1), this.getVertexBufferObjectManager());
this.mEngine.getTextureManager().loadTexture(this.bitmapTextureAtlas);
}
Run Code Online (Sandbox Code Playgroud)
最后,实例化场景并附加背景.
@Override
protected Scene onCreateScene() {
this.scene = new Scene();
this.scene.attachChild(this.background);
return this.scene;
}
Run Code Online (Sandbox Code Playgroud)
现在为什么这个小活动没有显示?我忘了:它是一个SimpleBaseGameActivity.
好吧,既然AndEngine GLES2没有在模拟器上运行,我必须使用我的手机(三星Galaxy GIO)并且无法在另一台机器上测试应用程序.
有没有人偶然发现类似的问题?非常感谢任何帮助,感谢您的时间!
我认为问题就在这里:
this.bitmapTextureAtlas = new BitmapTextureAtlas(this.getTextureManager(), 1024, 1600, TextureOptions.NEAREST);
Run Code Online (Sandbox Code Playgroud)
Atlas 的维度应该是 2 的幂。
归档时间: |
|
查看次数: |
3790 次 |
最近记录: |