ZombieSquirrel
Member
Hi everyone.
I was wondering about sprite rotation.
It's easy if you have a single sprite, with it's center centered, and then use
draw_sprite_general or draw_sprite_part_ext or something, and change the 'rot" value. This will always pivot a single sprite around the center point the way you want it to be.
However, I have a lot of objects (trees of different kinds, with multiple growth stages) in my game.
They are all nicely drawn on a spritesheet. I once imported each single image from that spritesheet separately, and did the above when my player cuts a tree, or if I want a storm to "swivel" the tree. Cut it => it fell down by rotating along the base center point, no sweat. It worked fine, but I had to adjust the graphical style and had to redraw them. Plus, importing such an amount is just crazy.
So, now I'm using a single spritesheet. I'd like to keep it that way because asset management is a big deal, the less imported files I have the better. Don't like something? Just change something on that one single .png spritesheet and done!. The game handles drawing using draw_sprite_part_ext in which I can choose which area on the spritesheet to draw. A bit more coding, but A LOT LESS tedious work (import => set center, test center, next sprite, import, set center, test center, …….) . In fact, it's a perfect learning tool for me because now I need to think about coding my own coordinate system when it comes to animating objects. Pretty much everything works great when things don't need to rotate. My sprites drawn and the object's mask are 2 different sprites. I don't need to rotate the object, just the coordinates in the objects DRAW event.
So now I'm at that point again: I need to rotate my trees when needed. This needs to happen at their base, not at the center of a sprite(part) drawn. I'm sure this problem is a common one...
So what I need to do is: determine the point to rotate around, the ROTATE POINT. If a sprite is 16x16 pixels, drawn at the object's x = 0 and y = 0, and i want to rotate around the center, then the rotating point is x+8 and x+8. If i want to rotate it around the center of the base, then the rotating point is x+8 and y+16. You get the idea.
So basically, my sprite ORIGIN needs to MOVE on a circle + the sprite needs to ROTATE around the ROTATE POINT.
The rotation and the movement need to be aligned for this, I'm aware of that. It's probably really tricky to do, but if I can do it by code, and not have to have a massive asset library, in which i determine each's sprite center point,... I would love that. It would be the final "hard thing" to learn for me when it comes to animating and drawing sprites.
I was wondering about sprite rotation.
It's easy if you have a single sprite, with it's center centered, and then use
draw_sprite_general or draw_sprite_part_ext or something, and change the 'rot" value. This will always pivot a single sprite around the center point the way you want it to be.
However, I have a lot of objects (trees of different kinds, with multiple growth stages) in my game.
They are all nicely drawn on a spritesheet. I once imported each single image from that spritesheet separately, and did the above when my player cuts a tree, or if I want a storm to "swivel" the tree. Cut it => it fell down by rotating along the base center point, no sweat. It worked fine, but I had to adjust the graphical style and had to redraw them. Plus, importing such an amount is just crazy.
So, now I'm using a single spritesheet. I'd like to keep it that way because asset management is a big deal, the less imported files I have the better. Don't like something? Just change something on that one single .png spritesheet and done!. The game handles drawing using draw_sprite_part_ext in which I can choose which area on the spritesheet to draw. A bit more coding, but A LOT LESS tedious work (import => set center, test center, next sprite, import, set center, test center, …….) . In fact, it's a perfect learning tool for me because now I need to think about coding my own coordinate system when it comes to animating objects. Pretty much everything works great when things don't need to rotate. My sprites drawn and the object's mask are 2 different sprites. I don't need to rotate the object, just the coordinates in the objects DRAW event.
So now I'm at that point again: I need to rotate my trees when needed. This needs to happen at their base, not at the center of a sprite(part) drawn. I'm sure this problem is a common one...
So what I need to do is: determine the point to rotate around, the ROTATE POINT. If a sprite is 16x16 pixels, drawn at the object's x = 0 and y = 0, and i want to rotate around the center, then the rotating point is x+8 and x+8. If i want to rotate it around the center of the base, then the rotating point is x+8 and y+16. You get the idea.
So basically, my sprite ORIGIN needs to MOVE on a circle + the sprite needs to ROTATE around the ROTATE POINT.
The rotation and the movement need to be aligned for this, I'm aware of that. It's probably really tricky to do, but if I can do it by code, and not have to have a massive asset library, in which i determine each's sprite center point,... I would love that. It would be the final "hard thing" to learn for me when it comes to animating and drawing sprites.
Last edited: