Author Topic: Animation-make it start the animation loop from the start each time  (Read 3435 times)

Jam0864

  • Contributor
  • Fanatic
  • **
  • Posts: 744
    • MSN Messenger - marmalade0864@hotmail.com
    • View Profile
    • Jam0864's Content Dump
    • Email
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?

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
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.

Jam0864

  • Contributor
  • Fanatic
  • **
  • Posts: 744
    • MSN Messenger - marmalade0864@hotmail.com
    • View Profile
    • Jam0864's Content Dump
    • Email
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

Jam0864

  • Contributor
  • Fanatic
  • **
  • Posts: 744
    • MSN Messenger - marmalade0864@hotmail.com
    • View Profile
    • Jam0864's Content Dump
    • Email
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
« Last Edit: 2007-09-23, 05:07:19 PM by Jam0864 »

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
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.

Jam0864

  • Contributor
  • Fanatic
  • **
  • Posts: 744
    • MSN Messenger - marmalade0864@hotmail.com
    • View Profile
    • Jam0864's Content Dump
    • Email
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

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
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.
Edward Dassmesser

Jam0864

  • Contributor
  • Fanatic
  • **
  • Posts: 744
    • MSN Messenger - marmalade0864@hotmail.com
    • View Profile
    • Jam0864's Content Dump
    • Email
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.  ;)

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
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?

Jam0864

  • Contributor
  • Fanatic
  • **
  • Posts: 744
    • MSN Messenger - marmalade0864@hotmail.com
    • View Profile
    • Jam0864's Content Dump
    • Email
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.