Page 1 of 1

Sprite Sheet Resulting on Unwanted Horizontal Motion

PostPosted: Fri Dec 21, 2012 5:23 am
by bamby1983
These are probably noob questions and it's my first sprite sheet. I mashed up the following in GIMP, which is suppose to be the top view of a soldier walking.

Image

This worked fine at first and the animation played in Game Editor as though the soldier was walking on the same spot. I then adjusted the layer sizes and cropped the edges of the canvas a bit (what you see above is the latest version, i.e., after the canvas cropping). When I load this in Game Editor, the animation moves horizontally and then restarts at the initial position. It looks like Game Editor is assuming that each frame is horizontally displaces a bit further than the previous one, resulting in a horizontal motion.

I performed this cropping because I wanted to center the individual layers in GIMP so that each soldier image in the sprite could be rotated around the central axis (so it looked as though he was actually turning and not jumping to a different position). I now have 16 sprite sheets (each containing the above animation but with each soldier rotated by an additional 22.5 degrees). Can I combine all these into a single sprite sheet and use this instead? It would help reduce the number of files in my "data" folder. How would I let Game Editor know which range of pictures to play at a given point of time? I'm guessing something on the lines of animpos, but would I need to write code to loop through each range of animations each time? Or is there a simpler way?

Re: Sprite Sheet Resulting on Unwanted Horizontal Motion

PostPosted: Fri Dec 21, 2012 6:12 am
by AliceXIII
This worked fine at first and the animation played in Game Editor as though the soldier was walking on the same spot. I then adjusted the layer sizes and cropped the edges of the canvas a bit (what you see above is the latest version, i.e., after the canvas cropping). When I load this in Game Editor, the animation moves horizontally and then restarts at the initial position. It looks like Game Editor is assuming that each frame is horizontally displaces a bit further than the previous one, resulting in a horizontal motion.


in my experience this usually happens when images arent aligned correctly. imagine you have two 32 X 32 pixel frames setup one with an image originating at 2x,2y meanwhile frame two has the same image but originating from 2x,0y.

when something like this happens in animated images it creates a jumpy looking animation in GE.

Re: Sprite Sheet Resulting on Unwanted Horizontal Motion

PostPosted: Fri Dec 21, 2012 9:55 am
by skydereign
What AliceXIII said is precisely the reason. You can't really crop the image, as it disrupts the alignment. Here is your image with the bounding boxes for the frames.
t6ulu9.png

If you want to crop it, you have to change the size of the bounding box for each frame. Think of it like a gif, where each next frame is simply above the current one. You can change the size of the image, but it won't change the alignment. This though only works if each frame is on top of the last. You can however crop the vertical component without messing up the alignment (since your animation strip is horizontal).

Re: Sprite Sheet Resulting on Unwanted Horizontal Motion

PostPosted: Sat Dec 22, 2012 3:32 am
by bamby1983
It worked after I adjusted the bounding box area as you said and made the spacing even on the sides as well. Thank you, I learnt something new today! :)