Last active
December 11, 2015 20:59
-
-
Save biggz/4659289 to your computer and use it in GitHub Desktop.
Libgdx Camera
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
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