jichoul shin
jichoul shin

Reputation: 71

Libgdx, How can rotate multiple texture same like one texture?

enter image description here

I want to rotate multiple texture same like this picture on libgdx.

How can do this? Please help me.

Upvotes: 2

Views: 226

Answers (1)

sorifiend
sorifiend

Reputation: 6307

You can rotate them the same as you do for a single texture, but you need to set the origin point for each texture to the centre of the rotation arc (bottom left point in the case of your image), so some basic maths will be required on your part to set each texture correctly so that the further away ones rotate around the same point as the closest texture.

Rotation from origin point example

From the API: https://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/Sprite.html

//Set the origin in relation to the sprite's position for scaling and rotation.
yourSprite.setOrigin(float originX, float originY)

//Sets the sprite's rotation in degrees relative to the current rotation.
//Rotation is centered on the origin set in setOrigin(float, float)
yourSprite.rotate(float degrees)

These questions and answers may help you:

https://gamedev.stackexchange.com/a/75330

https://gamedev.stackexchange.com/questions/119870/libgdx-sprite-rotation-around-specific-point

Upvotes: 1

Related Questions