Aquí os pego el código del ejemplo anterior modificado para que se mueva verticalmente.
public class BaseActivity extends SimpleBaseGameActivity {
private static final int CAMERA_WIDTH = 800;
private static final int CAMERA_HEIGHT = 480;
private BitmapTextureAtlas mAutoParallaxBackgroundTexture;
private ITextureRegion mParallaxFondo;
public EngineOptions onCreateEngineOptions() {
final Camera camera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);
return new EngineOptions(true, ScreenOrientation.LANDSCAPE_FIXED, new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT), camera);
}
@Override
public void onCreateResources() {
BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");
this.mAutoParallaxBackgroundTexture = new BitmapTextureAtlas(this.getTextureManager(),800, 480, TextureOptions.BILINEAR_PREMULTIPLYALPHA);
this.mParallaxFondo = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.mAutoParallaxBackgroundTexture, this, "fondoAP.png", 0,0);
this.mAutoParallaxBackgroundTexture.load();
}
@Override
public Scene onCreateScene() {
this.mEngine.registerUpdateHandler(new FPSLogger());
final Scene scene = new Scene();
final VerticalAutoParallaxBackground autoParallaxBackground = new VerticalAutoParallaxBackground(0,0,0,20);
final VertexBufferObjectManager vertexBufferObjectManager = this.getVertexBufferObjectManager();
autoParallaxBackground.attachParallaxEntity(new ParallaxEntity(5.0f, new Sprite(0, 0, this.mParallaxFondo, vertexBufferObjectManager)));
scene.setBackground(autoParallaxBackground);
return scene;
}
}
No está nada mal, pero unas imágenes o pequeños videos con los resultados lo mejorarían bastante.
ResponderEliminarEnhorabuena por los tutoriales, espero que sigas así!
Hola, enhorabuena por el blog, estoy intentando usar estas modificaciones pero no consigo que la imagen que he puesto de fondo ademas de hace el scroll vertical, se escale horizontalmente ya que esta es un poco mas pequeña que la resolucion. ¿Podrias echarme una mano?
ResponderEliminar