如何在libgdx中的x轴上旋转图像?

时间:2017-04-24 22:24:18

标签: java android libgdx

我正在尝试在x轴上旋转图像,但它不起作用

WORD,[here]

1 个答案:

答案 0 :(得分:1)

在批次上绘制纹理时,可以正确旋转纹理。

SpriteBatch.draw(textureRegion.getTexture(), x, y, originX, originY, width, height, scaleX, scaleY, rotation, srcX, srcX, srcWidth, srcHeight, false, false);

以上是在x轴,y轴或两者中旋转图像所需的确切代码。

其中:

x - the x-coordinate in screen space
y - the y-coordinate in screen space

originX - the x-coordinate of the scaling and rotation origin relative to the screen space coordinates
originY - the y-coordinate of the scaling and rotation origin relative to the screen space coordinates

width - the width in pixels
height - the height in pixels

scaleX - the scale of the rectangle around originX/originY in x
scaleY - the scale of the rectangle around originX/originY in y

rotation - the angle of counter clockwise rotation of the rectangle around originX/originY

srcX - the x-coordinate in texel space
srcY - the y-coordinate in texel space

srcWidth - the source with in texels
srcHeight - the source height in texels