- 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();
- }
viernes, 3 de agosto de 2012
Tutorial Sprite Background AndEngine GLES 2.0
Colocar un Sprite de fondo se hace de la misma manera que colocar un Sprite en la pantalla. Casi todos los pasos son iguales al tutorial anterior si os dejo pegado el código y solo explico lo que es diferente.
Tutorial Sprite AndEngine GLES2
Lo primero que tenemos que hacer es configurar AndEngine GLES 2.0. Los pasos para ello los tenéis en el tutorial anterior. Tras esto creamos una carpeta en nuestro proyecto denominada assets y dentro de ella otra llamada gfx, e introducimos ahí nuestra imagen a cargar.
Ahora creamos tres variables. Una sera un BitmapTexture que es el lienzo donde introducimos nuestros sprites, otra sera una ITextureRegion y otro un objeto Sprite.
En esta parte podemos definir antes las variables CAMERA_WIDTH y CAMERA_HEIGHT antes, o introducir los datos directamenta en la función. Yo las he definido antes.
Ahora creamos tres variables. Una sera un BitmapTexture que es el lienzo donde introducimos nuestros sprites, otra sera una ITextureRegion y otro un objeto Sprite.
Ahora definiremos la camara en onCreateEngineOptions().
- private ITextureRegion mEnemigoTextureRegion;
- private BitmapTextureAtlas mBitmapTextureAtlas;
- public Sprite enemigo;
- 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);
En esta parte podemos definir antes las variables CAMERA_WIDTH y CAMERA_HEIGHT antes, o introducir los datos directamenta en la función. Yo las he definido antes.
- private static final int CAMERA_WIDTH = 800;
- private static final int CAMERA_HEIGHT = 480;
Suscribirse a:
Entradas (Atom)