user3165683
user3165683

Reputation: 367

Rotating sprite in java LibGDX

Have an asset class for the sprite which defines a texture, then the sprite as that texture sheet, with coordinates for the sheet. this is the sprite i am trying to rotate. I have been given the advice to rotate it using Sprite Batch (it rotates to my touch input:

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

and i get the error:

The method draw(Texture, float, float, int, int, int, int) in the type SpriteBatch is not applicable for the arguments (Sprite, int, int, int, int, int, int, int, float)

Is there a sort of way to cast a sprite to a texture or a better way to rotate it it just isn't working please help!

Upvotes: 0

Views: 923

Answers (1)

SoftRock
SoftRock

Reputation: 96

You can simply use the rotate(float degrees) . Sets the sprite's rotation in degrees relative to the current rotation.

you must use the rotate(float degrees) in render method of your class.

as given in Sprite Class documentation

Upvotes: 1

Related Questions