【发布时间】:2012-06-07 14:22:34
【问题描述】:
我想设置我的场景背景,但我不知道如何设置!我已经阅读了很多关于此的内容,但我无法使其正常工作。是我从 Andengine 开始的,并且很难找到我的问题的准确信息,一切都是主观的。
好吧,我已经在一个场景中实现了启动画面,同时加载了所有资源和场景。 (https://sites.google.com/site/matimdevelopment/splash-screen---easy-way)
然后,我必须为我的 menuScene 设置一个背景,我认为我需要一个 TextureRegion 和一个 BitmapTextureAtlas 来创建每个背景。我这样做:
声明的纹理:
//Fondo escenas
private TextureRegion menuBgTexture;
private BitmapTextureAtlas menuBackgroundTexture;
加载资源和加载场景(在 Splash 结束时由 onPopulateScene 调用)
public void loadResources()
{
//FondoMenu
menuBackgroundTexture = new BitmapTextureAtlas(null, 480, 320, TextureOptions.DEFAULT);
menuBgTexture = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.menuBackgroundTexture, this, "menubg.png", 0, 0);
//Cargamos los fondos
mEngine.getTextureManager().loadTexture(this.menuBackgroundTexture);
}
private void loadScenes()
{
//Menú
menuScene = new Scene();
final float centerX = (CAMERA_WIDTH - menuBgTexture.getWidth()) / 2;
final float centerY = (CAMERA_HEIGHT - menuBgTexture.getHeight()) / 2;
SpriteBackground bg = new SpriteBackground(new Sprite(centerX, centerY, menuBgTexture));
menuScene.setBackground(bg);
//menuScene.setBackground(new Background(50, 0, 0));
//Options
optionsScene = new Scene();
//Juego
gameScene = new Scene();
//Pausa
pauseScene = new Scene();
//Gameover
gameOverScene = new Scene();
}
加载资源不显示错误,但 loadScenes,行: SpriteBackground bg = new SpriteBackground(new Sprite(centerX, centerY, menuBgTexture));
说我要设置一个新属性(ISpriteVertexBufferObject),嗯,这是什么?
【问题讨论】:
-
您使用的是哪个 GLES? GLES2?我在 GLES2 中有 onCreateResources()。我不知道为什么 Nicolas Gramlich 决定像这样重命名关键函数,以及为什么他创建了一个没有文档的引擎/库。有人可以提供帮助吗?
-
谁知道他在文档方面的想法,上帝禁止你在 andengine 论坛上谈论这个,如果你被告知你应该阅读源代码并工作它出来了,我的意思是这一切都很好,但在源代码中甚至没有任何 cmets。真可惜,它是一个不错的小型开源引擎,只是我的两分钱:D
-
我也面临着类似的问题...我无法设置我的背景...这里是代码 ..menuBackgroundTexture = new BitmapTextureAtlas(null, 2*CAMERA_WIDTH, 2*CAMERA_HEIGHT, TextureOptions.默认); menuBgTexture = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.menuBackgroundTexture, this, "land.png", 0, 0); SpriteBackground bg = new SpriteBackground(new Sprite(0, 0, menuBgTexture,this.getVertexBufferObjectManager())); mScene.setBackground(bg);....谁能帮帮我?
标签: android background andengine scene