Skip to content

Instantly share code, notes, and snippets.

@biggz
Last active December 11, 2015 20:59
Show Gist options
  • Save biggz/4659289 to your computer and use it in GitHub Desktop.
Save biggz/4659289 to your computer and use it in GitHub Desktop.
Libgdx Camera
OrthographicCamera camera;
Rectangle glViewport;
SpriteBatch spriteBatch;
public BSPScreen(ActionRPG tmpGame){
spriteBatch = new SpriteBatch();
LoadAssets();
}
@Override
public void render(float delta) {
Gdx.gl.glClearColor(0.294f, 0.294f, 0.294f, 1f);
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
//Gdx.gl.glViewport((int)glViewport.x, (int)glViewport.y, (int)glViewport.width, (int)glViewport.height);
camera.update();
spriteBatch.setProjectionMatrix(camera.combined);
spriteBatch.begin();
spriteBatch.draw(d_f, 1f,1f);
spriteBatch.end();
}
@Override
public void resize(int width, int height) {
glViewport = new Rectangle(0, 0, width, height);
float aspectRatio = (float) width / (float) height;
camera = new OrthographicCamera();
camera.setToOrtho(false, 10f*aspectRatio, 10f);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment