Thypari
Thypari

Reputation: 861

libgdx - sprite does not rotate

This is the create() Method:

batch = new SpriteBatch();
texture = new Texture(Gdx.files.internal("spaceships/tfighter0.png"));
sprite = new Sprite(texture);
sprite.setOrigin(sprite.getWidth()/2, sprite.getHeight()/2);
sprite.rotate(180f);

And the render() Method:

Gdx.gl.glClearColor(0, 0, 0, 0);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin();
batch.draw(sprite ,200,200);
batch.end();

Shouldn't the sprite be rotated now? It just looks the same as the png no matter what degree I put into the rotate method.

Upvotes: 0

Views: 1190

Answers (1)

Thypari
Thypari

Reputation: 861

Using

sprite.draw(batch)

Instead of

batch.draw(sprite,x,y)

works

Upvotes: 3

Related Questions