- public class Main extends SimpleBaseGameActivity {
- private static final int CAMERA_WIDTH = 800;
- private static final int CAMERA_HEIGHT = 480;
- private ITextureRegion mFondoTextureRegion;
- private BitmapTextureAtlas mFondoTextureAtlas;
- public EngineOptions onCreateEngineOptions() {
- final Camera camera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);
- return new EngineOptions(true, ScreenOrientation.LANDSCAPE_SENSOR, new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT), camera);
- }
- public void onCreateResources() {
- BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");
- this.mFondoTextureAtlas = new BitmapTextureAtlas(this.getTextureManager(), 1500, 1500);
- this.mFondoTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.mFondoTextureAtlas, this, "fondo.png", 0, 0);
- this.mFondoTextureAtlas.load();
- }
Lo único que cambia es en onCreateScene(). Definimos nuestra escena como antes y
,definimos el sprite de fondo e introducimos setBackground(). Así quedaría onCreateScene():
- public Scene onCreateScene() {
- final Scene escena = new Scene();
- final Sprite fondo = new Sprite(0, 0, this.mFondoTextureRegion, this.getVertexBufferObjectManager());
- scene.setBackground(new SpriteBackground(fondo));
- return scene;
- }
No hay comentarios:
Publicar un comentario