🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Problem with rotate image in slick2d

Started by
6 comments, last by Alberth 4 years, 2 months ago

When i rotate img(Image.setRotation),then Image.draw(x1,y1,x2,y2) does not display correctly.But when i didn't rotate image ,then al is ok

Advertisement

“does not display correctly” can mean just about anything, you may want to elaborate on your statement. One option is to make a screenshot with an explanation how the result is not correct. Likely it also helps if you define where your coordinates are.

BTW: Did you check the manual what should happen if you paint a rotated image?

@Alberth ,I mean, the image is not drawn in the coordinates that I indicated. But below and to the right of the specified location.
I even did drawRect on the same coordinates, but everything is fine.
The only thing that affects the incorrect display of Image is setRotation

It's possible the image rotates around a point you don't expect.

@alvaro

alvaro said:

It's possible the image rotates around a point you don't expect.

How can I customize this?How i find out around what point?

According to the documentation this would likely be Image.centerX and Image.centerY.

It's always a good idea though to have some tutorials or solid descriptions ready of the API you're using. Sometimes the requirements aren't that obvious so that could save you a lot of debugging.

stavatar28 said:
I mean, the image is not drawn in the coordinates that I indicated. But below and to the right of the specified location. I even did drawRect on the same coordinates, but everything is fine. The only thing that affects the incorrect display of Image is setRotation

Likely above are the answers already, but for future reference: Great that is paints the rectangle, basically it works thus, but only not entirely at the right spot. Doing tests like drawRect and eliminating other causes is very useful as well.

stavatar28 said:
How can I customize this?How i find out around what point?

The former is in the documentation if it is anywhere. About the latter, be creative, don't draw 1 rectangle but draw several.

You could for example try to draw one rotated and one not-rotated, so you can see how the image changes.

Another option is to draw several times the same rectangle at the same coordinates, but with slightly different angles. The rotation point should be at the spot that doesn't move.

This topic is closed to new replies.

Advertisement