AndEngine场景加载资源
请帮助我,我的代码有什么问题吗?在设备上显示黑色背景。
public void onLoadResources()
{
this.mTexture = new Texture(1024, 1024);
this.mTextureRegion = TextureRegionFactory.createFromAsset(this.mTexture, this, "gfx/bgr.png",0,0);
this.getEngine().getTextureManager().loadTexture(this.mTexture);
}
@Override
public Scene onLoadScene()
{
final Scene scene = new Scene(1);
backLayer=new Sprite(0,0,this.mTextureRegion);
scene.getTopLayer().addEntity(backLayer);
return scene;
}
Help me please, wat's wrong in my code? On device shown black background.
public void onLoadResources()
{
this.mTexture = new Texture(1024, 1024);
this.mTextureRegion = TextureRegionFactory.createFromAsset(this.mTexture, this, "gfx/bgr.png",0,0);
this.getEngine().getTextureManager().loadTexture(this.mTexture);
}
@Override
public Scene onLoadScene()
{
final Scene scene = new Scene(1);
backLayer=new Sprite(0,0,this.mTextureRegion);
scene.getTopLayer().addEntity(backLayer);
return scene;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我为您提供了一些解决方案:
Scene(int)
,它已弃用。请改用Scene()
。scene.setBackground(new SpriteBackground(backLayer));
,而不是scene.getTopLayer().addEntity(backLayer);
。最后,我在
TextureRegionFactory
中没有看到createFromAsset
方法。也许您应该更新您的 AndEngine 类?并尝试这个,可能会起作用:I have a few fixes for you:
Scene(int)
, its deprecated. UseScene()
instead.scene.setBackground(new SpriteBackground(backLayer));
, instead ofscene.getTopLayer().addEntity(backLayer);
.Lastly, I didn't see the method
createFromAsset
inTextureRegionFactory
. Maybe you should update your AndEngine classes? And try this instead, might work: