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

问题描述:

我试图在其x轴旋转的图像,但它不工作如何在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.setScale(2f,2f); 
oneImg.addAction(rotateBy(360, 0.5f)); 
+0

在2D中,可以通过从1到-1在y方向上缩放和背面使用正确的(窦)内插 –

+0

模拟x轴旋转可以请你告诉我一个简单的代码那实现了吗? –

当你画它的批次您可以旋转你的纹理权。

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