2
\$\begingroup\$

I would like to get the position of each edge of a sprite when he has been rotated.

I have no idea how to do it, I made a image to explain it.

I would like to get the X and Y position of each Red circles please thanks you .

Sprite sprite = new Sprite(texture);
sprite.setRotation(-20);

enter image description here

\$\endgroup\$
4
\$\begingroup\$

To get the rotated sprites coordinate simply call the getVertices() method.

For example: sprite.getVertices()[SpriteBatch.X2]

Gets you the X coordinates of the top left corner.

The same call but replacing X<number> with Y<number> gets you the Y coordinate.

The corner numbers go like this:

2-3
| |
1-4
| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.