Problem with rotation sprite in LibGdx. The sprite doesn't rotate

306 Views Asked by At

When I try to rotate an object around its axis around its axis a sprite of game objects I using the rotate() and setRotation() commands, the sprite does not rotate.

Also, when I try to rotate the actor I using the rotateBy() and setRotation() commands, nothing happens too.

In my project, drawing game objects (actors) occurs via the draw() method in Stage.

I noticed that if I draw an object using the batch.draw(sprite, x, y) method, the object will not rotate.

code from public class MyGdxGame extends ApplicationAdapter

@Override
public void render () {
    Gdx.gl.glClearColor(1, 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    batch.begin();
    batch.draw(sprite, 0, 0);
    sprite.rotate(1);
    batch.end();
}

And if I draw an object using the sprite.draw(batch) method, the object rotates calmly.

@Override
public void render () {
    Gdx.gl.glClearColor(1, 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    batch.begin();
    sprite.draw(batch);
    sprite.rotate(1);
    batch.end();
}

Perhaps this is the reason for my problem.

0

There are 0 best solutions below