j0t3x
11/22/2013 - 1:52 AM

videotutorial 2

videotutorial 2

import java.io.IOException;

import org.andengine.engine.camera.Camera;
import org.andengine.engine.options.EngineOptions;
import org.andengine.engine.options.ScreenOrientation;
import org.andengine.engine.options.WakeLockOptions;
import org.andengine.engine.options.resolutionpolicy.FillResolutionPolicy;
import org.andengine.entity.scene.Scene;
import org.andengine.entity.sprite.Sprite;
import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlas;
import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory;
import org.andengine.opengl.texture.region.TextureRegion;
import org.andengine.ui.activity.SimpleBaseGameActivity;

public class MainActivity extends SimpleBaseGameActivity{

	private Camera camara;
	private static float ANCHO = 800;
	private static float ALTO = 480;
	private BitmapTextureAtlas atlas;
	private TextureRegion texturaP;
	private Scene escena;
	private Sprite personaje;
	
	@Override
	public EngineOptions onCreateEngineOptions() {
		// Definimos nuestra camara
		camara = new Camera(0, 0, ANCHO, ALTO);
		// Ahora declaramos las opciones del motor
		EngineOptions eo = new EngineOptions(true, ScreenOrientation.LANDSCAPE_FIXED, new FillResolutionPolicy(), camara);
		//EngineOptions(es full screen?, Cual es la orientacion de la pantalla?, Como actuaremos ante distintas resoluciones?, y la camara)
		eo.setWakeLockOptions(WakeLockOptions.SCREEN_ON);		
		// impedimos que la pantalla se apague por inactividad
		
		return eo;
	}

	@Override
	protected void onCreateResources() throws IOException {
	
		BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");
		
		atlas = new BitmapTextureAtlas(getTextureManager(), 75, 96);
		
		texturaP = BitmapTextureAtlasTextureRegionFactory.createFromAsset(atlas, this, "char.png", 0, 0);
		
		atlas.load();
		
		
	}

	@Override
	protected Scene onCreateScene() {
		escena = new Scene();
		
		personaje = new Sprite(100, 100, texturaP, getVertexBufferObjectManager());
		
		escena.attachChild(personaje);

		
		
		return escena;
	}

}