Search code examples
javaimagerotationlibgdxatlas

Rotate Atlas Region Libgdx


protected TextureAtlas atlas = Assets.manager.get(Constants.ATLAS_PATH, TextureAtlas.class);

AtlasRegion region = interfaceAtlas.findRegion("arrow");

I've load an image like this (http://marinedealerconference.com/wp-content/uploads/2015/07/right.png): an arrow that points right...

But I can't find a way to rotate it! How can I? Because I want it goes down.


Solution

  • you cannot rotate region although you can rotate Sprite or Image

        //sprite:
        public void rotate(float degrees)
    
        //image - remember to set origin to the center here!
        public void rotateBy(float amountInDegrees)
    

    Instead of rotating the region itself you can "tell" SpriteBatch to draw it rotated:

        batch.draw(region, x, y, originX, originY, width, height, scaleX, scaleY, rotation);