Java 发动机不能显示雪碧
在Android Studio中,我试图用AndEngine创建一个精灵,但它无法显示精灵,它只显示一个黑屏。我搜索并尝试了几个小时不同的方法 结构如下:Java 发动机不能显示雪碧,java,android,drawable,andengine,Java,Android,Drawable,Andengine,在Android Studio中,我试图用AndEngine创建一个精灵,但它无法显示精灵,它只显示一个黑屏。我搜索并尝试了几个小时不同的方法 结构如下: -myApplication -andEngine -app -res -drawable -stand.png 代码如下: @Override public void onCreateResources() { this.mBitmapText
-myApplication
-andEngine
-app
-res
-drawable
-stand.png
代码如下:
@Override
public void onCreateResources() {
this.mBitmapTextureAtlas = new BitmapTextureAtlas(getTextureManager(), 30, 30, TextureOptions.DEFAULT);
mPlayerTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromResource(mBitmapTextureAtlas, this, R.drawable.stand, 0, 0);
mBitmapTextureAtlas.load();
}
@Override
public Scene onCreateScene() {
this.mEngine.registerUpdateHandler(new FPSLogger());
this.mMainScene = new Scene();
this.mMainScene.setBackground(new Background(1, 1, 1));
final Sprite oPlayer = new Sprite(100, 100, mPlayerTextureRegion, getVertexBufferObjectManager());
this.mMainScene.attachChild(oPlayer);
return this.mMainScene;
}
任何帮助都将不胜感激
谢谢。检查您的日志,这可能是个例外
mPlayerTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromResource(mBitmapTextureAtlas, this, R.drawable.stand, 0, 0);
当我检查代码时,这一行可能是异常的原因
mPlayerTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromResource(mBitmapTextureAtlas, this, R.drawable.stand, 0, 0);
在创建
BitmapTextureAtlas
的对象时,检查支架的尺寸。png
不得大于30*30
,否则传递更大的值 我已经用JBox2d完成了游戏,如果我有时间,我可以用AndEngine再次测试它,无论如何,谢谢。