How Can I Rotate An Image Over Its X Axes In Libgdx?
I'm trying to rotate an image over its x axes but its not working Texture one = new Texture(Gdx.files.internal('img/one.jpg')); oneImg = new Image(one); oneImg.setOrigin(oneImg.ge
Solution 1:
You can rotate your texture right when you draw it on the batch.
SpriteBatch.draw(textureRegion.getTexture(), x, y, originX, originY, width, height, scaleX, scaleY, rotation, srcX, srcX, srcWidth, srcHeight, false, false);
So above is the exact code that you need to rotate your image in x-axis, y-axis or both.
where :
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
Post a Comment for "How Can I Rotate An Image Over Its X Axes In Libgdx?"