gpt4 book ai didi

java - 我如何在 libgdx 中将图像旋转到其 x 轴上?

转载 作者:太空狗 更新时间:2023-10-29 13:52:59 24 4
gpt4 key购买 nike

我试图在其 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.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

关于java - 我如何在 libgdx 中将图像旋转到其 x 轴上?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43598646/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com