Java 如何在libgdx中沿图像的x轴旋转图像?
我试图在x轴上旋转图像,但它不工作Java 如何在libgdx中沿图像的x轴旋转图像?,java,android,libgdx,Java,Android,Libgdx,我试图在x轴上旋转图像,但它不工作 Texture one = new Texture(Gdx.files.internal("img/one.jpg")); oneImg = new Image(one); oneImg.setOrigin(oneImg.getWidth() / 2, oneImg.getHeight() / 2); oneImg.setPosition(stage.getWidth() / 2-32 , stage.getHeight()/2); oneImg.setSca
Texture one = new Texture(Gdx.files.internal("img/one.jpg"));
oneImg = new Image(one);
oneImg.setOrigin(oneImg.getWidth() / 2, oneImg.getHeight() / 2);
oneImg.setPosition(stage.getWidth() / 2-32 , stage.getHeight()/2);
oneImg.setScale(2f,2f);
oneImg.addAction(rotateBy(360, 0.5f));
在批次上绘制纹理时,可以向右旋转纹理
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
在2d中,您可以通过在y方向上从1缩放到-1,然后使用正确的(窦状)插值来模拟x轴旋转。您能给我一个简单的代码实现吗?