Reputation: 1850
I wanna set My Scene Background but I don't know how! I had read a lot about this, but I can't make this works. Is my start with Andengine, and is hard found precise information for my problem, all is subjective.
Well, I have implemented the splash screen in a scene, and while load all resources and scenes. (https://sites.google.com/site/matimdevelopment/splash-screen---easy-way)
Then, I have to set a Background to my menuScene, I think that I need a TextureRegion and a BitmapTextureAtlas to create each backgroud. I do this:
Declared textures:
//Fondo escenas
private TextureRegion menuBgTexture;
private BitmapTextureAtlas menuBackgroundTexture;
Load Resources and Load scenes (They are called by onPopulateScene when Splash ends)
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();
}
load Resource not shows error, but loadScenes, Line: SpriteBackground bg = new SpriteBackground(new Sprite(centerX, centerY, menuBgTexture));
Says me that I have to set a new attribute (ISpriteVertexBufferObject), well, what is this?
Upvotes: 5
Views: 8643
Reputation: 45
I also had the same issue with my game. The solution is to have a background image that is of the same dimensions as the camera. For example, if your camera is 800X480, the image should be of the same dimensions as well. Also, make the dimensions of the BitmapTextureAtlas factors of two. In your case, it should be 512px by 512 px. Hope that helps.
Cheers!!
Upvotes: 1
Reputation: 2527
for the VBOManager object, use
this.getVertexBufferObjectManager();
Upvotes: 2