Libgdx,如何像一个纹理一样旋转多个纹理?

时间:2017-05-05 01:52:43

标签: java libgdx rotation textures

enter image description here

我想在libgdx上旋转多个像这张图片一样的纹理。

怎么办呢?请帮帮我。

1 个答案:

答案 0 :(得分:1)

您可以像对单个纹理一样旋转它们,但是您需要将每个纹理的原点设置为旋转圆弧的中心(在图像的情况下为左下角),所以一些基本的您需要使用数学来正确设置每个纹理,以使更远的纹理围绕与最接近纹理相同的点旋转。

Rotation from origin point example

来自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)

这些问题和答案可能会对您有所帮助:

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

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