[SOLVED] A serious (and probably very silly) question about object/image rotation

GMWolf

aka fel666
Note that gamemakers doesn't really deal with discrete pixels.

What you don't see happening under the good, is that a sprite being drawn is really a textured rectangle being drawn.
The rectangle coordinates are not discrete pixels (you can have sub pixel accuracy).

The result of that is that the rectangle can be rotated around any coordinates.

If you wanted to rotate your rectangle around it's true centre, you would have to rotate it around the point (1.5, 1.5).

Here? Since you set the origins to (1, 1), you are not rotating around the centre, but the point (1, 1).

That is unless GM does something wierd under the hood (like add .5 to origine coordinates to 'fix' this).
 

Nixxi

Member
Well, the reason for the question is we're arguing over whether our sprites should be authored at an odd resolution or an even resolution so that when they rotate from the center they aren't uneven or "lopsided". If there is a definitive answer to this that would be helpful.
 

Mick

Member
Well, the reason for the question is we're arguing over whether our sprites should be authored at an odd resolution or an even resolution so that when they rotate from the center they aren't uneven or "lopsided". If there is a definitive answer to this that would be helpful.
A sprite rotates with the pixel at the origin being center. To get an even rotation, you would best have sprites with odd width and height. So a sprite that has a size of 5x5px will rotate evenly if it's origin is set at x=2, y=2.

EDIT: So seems like the above is BS, I guess it should read: A sprite rotates with the origin being center. To get an even rotation, you would best have sprites with even width and height. So a sprite that has a size of 4x4px will rotate evenly if it's origin is set at x=2, y=2.
 
Last edited:

Nixxi

Member
A sprite rotates with the pixel at the origin being center. To get an even rotation, you would best have sprites with odd width and height. So a sprite that has a size of 5x5px will rotate evenly if it's origin is set at x=2, y=2.
Thank you! That's what I needed to hear! ...er, read!
 

GMWolf

aka fel666
A sprite rotates with the pixel at the origin being center. To get an even rotation, you would best have sprites with odd width and height. So a sprite that has a size of 5x5px will rotate evenly if it's origin is set at x=2, y=2.
So did I suspect correctly?
GM does do weird things and adds 0.5 to your origin coordinate?
 

Mick

Member
So did I suspect correctly?
GM does do weird things and adds 0.5 to your origin coordinate?
Damn, i remember incorrectly, seems you are right, the sprite needs to be even width and height with the origin at centre.

Thank you! That's what I needed to hear! ...er, read!
I'm sorry, looks I had this the wrong way round! I just tested (in GMS) with a circle sprite with even width and height and the origin set at centre. It is rotating correctly, while a sprite with an uneven width and height with the origin set at centre rotates unevenly. So please re-read my edited post above!
 
Last edited:

GMWolf

aka fel666
Damn, i remember incorrectly, seems you are right, the sprite needs to be even width and height with the origin at centre.
Ah ok. I didnt test it myself but it seemed weird...


... wait. Now I'm confused as to what GM does... I'm gonna have to test it for myself just to wrap my head arouhnd it :)
 
unless there's something I don't know, the origin always has to be located at the corner of a pixel, meaning you need to have an even height/width for the origin to be able to be at the center of the sprite.
 
Top