Created
November 22, 2013 01:52
-
-
Save j0t3x/7593488 to your computer and use it in GitHub Desktop.
videotutorial 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment