So I have been experimenting with the Ortho-something-Camera and I cant get the behavior I want.
For example, when I render a sprite at position 0,0, it should be rendered at the top left corner. But thats not the case here.
Furthermore, when I increase the y-variable, the entity moves up. It should move down.
Here is my code:
float x, y;
@Override
public void create()
{
cam = new OrthographicCamera(800, 600); //This is the size of the window.
batch = new SpriteBatch();
texture = new Texture(Gdx.files.internal("data/libgdx.png"));
sprite = new Sprite(new TextureRegion(texture));
sprite.setOrigin(0,0);
sprite.setPosition(-sprite.getWidth()/2,-sprite.getHeight()/2);
}
@Override
public void render()
{
cam.position.set(0,0,0);
cam.update();
Gdx.gl.glClearColor(1, 1, 1, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.setProjectionMatrix(cam.combined);
batch.begin();
batch.draw(sprite,x,y);
batch.end();
}
What am I doing wrong?