Scrolling Game Development Kit Forum

SGDK Version 2 => Help, Errors, FAQ => Topic started by: Jam0864 on 2007-09-23, 02:17:50 AM

Title: Animation-make it start the animation loop from the start each time
Post by: Jam0864 on 2007-09-23, 02:17:50 AM
I have the stickman sprite going fairly nicely.
Bad thing is, when it jumps, the jumping animation is in a loop, so when it goes into that state, it doesnt necessarily start at the start of the animation, sometimes halfway through or at the end. D= How can I fix this?
Title: Re: Animation-make it start the animation loop from the start each time
Post by: bluemonkmn on 2007-09-23, 06:49:18 AM
Maybe you can add rules to set the frame based on the vertical velocity (dy).  If dy < -1 then set frame to 0, else if dy < 1 then set frame to 1 else set frame to 2 (if you have 3 frames for example).  This would use frame 0 for the part of the jump where the sprite's vertical velocity is upward at more than 1 pixel per frame, 1 when the sprite's vertical velocity is 1 pixel per frame or less in either direction, and 2 when it's falling back down at more than 1 pixel per frame.  You'd want to make sure it only does this while in a jumping state, though.  Think that'd work?

Or just make sure frame is 0 when you start the jump and see how much that improves things.
Title: Re: Animation-make it start the animation loop from the start each time
Post by: Jam0864 on 2007-09-23, 06:56:49 AM
hmm, that sounds like it should work. I'll try it in the morning as I'm like too tired to do anything atm... lol
Title: Re: Animation-make it start the animation loop from the start each time
Post by: Jam0864 on 2007-09-23, 04:47:47 PM
Alright that's now working. =D
Now I just gotta do the ladder climbing D=
EDIT:// The solidity isn't working correctly either, i haven't added hills yet, but on the normal flat tiles, the sprite sinks in a little bit for some reason. D=
http://www.box.net/shared/jlln5ax4mi  (http://www.box.net/shared/jlln5ax4mi)
Title: Re: Animation-make it start the animation loop from the start each time
Post by: bluemonkmn on 2007-09-24, 05:41:08 AM
The images for your sprite are 45 pixels high, but the heights of your sprite states are defined as 32 pixels.  That's a relatively easy thing to fix in the sprite definition state editor.  That's a pretty cool sprite you got going there.  It demonstrates something new to SGDK2 (something that was difficult and uncommon in 1.x) -- sprites with jumping animations... and a pretty nice one at that.  Keep up the good work.  I may just have to use that sprite myself when it's ready.
Title: Re: Animation-make it start the animation loop from the start each time
Post by: Jam0864 on 2007-09-24, 06:54:10 AM
The images for your sprite are 45 pixels high, but the heights of your sprite states are defined as 32 pixels.  That's a relatively easy thing to fix in the sprite definition state editor.
ahh, i see. lol

Quote from: bluemonkmn
that's a pretty cool sprite you got going there.  It demonstrates something new to SGDK2 (something that was difficult and uncommon in 1.x) -- sprites with jumping animations... and a pretty nice one at that.  Keep up the good work.  I may just have to use that sprite myself when it's ready.
;D
Title: Re: Animation-make it start the animation loop from the start each time
Post by: durnurd on 2007-09-24, 07:59:48 AM
Although you may want to clean up the code a bit.  Give things meaningful names, for example, use else-ifs instead of a series of ifs, and at least one place you use if IsInState several times in a row to determine if a sprite is Not in a state, which would be more simply done by using the Not checkbox.
Title: Re: Animation-make it start the animation loop from the start each time
Post by: Jam0864 on 2007-09-24, 06:12:42 PM
Quote
for example, use else-ifs instead of a series of ifs,
I'm not really sure of what the else-ifs, elses and whiles, do, thats why i never use them. lol

Quote
and at least one place you use if IsInState several times in a row to determine if a sprite is Not in a state, which would be more simply done by using the Not checkbox.
oh yeah... I'm fixing that up now.  ;)
Title: Re: Animation-make it start the animation loop from the start each time
Post by: bluemonkmn on 2007-09-24, 06:20:52 PM
I'm not really sure of what the else-ifs, elses and whiles, do, thats why i never use them. lol

Have you looked at the documentation to try to understand them?
Title: Re: Animation-make it start the animation loop from the start each time
Post by: Jam0864 on 2007-09-24, 07:24:44 PM
nope, since everything was working fine without them, i didn't bother. I shall look at the documentation a bit, when i start working on the sprite again.