Author Topic: Animation related question  (Read 3888 times)

Vincent

  • SGDK2 Addict
  • Expert
  • Fanatic
  • *****
  • Posts: 612
  • Legacy of Kain: Revival is completed!!!
    • View Profile
    • Chivalrous Games
    • Email
Animation related question
« on: 2008-01-14, 12:55:48 PM »
Hello everyone!

I have a quick question for you guys.  I think I looked everywhere, but I couldn't find an answer.  I'm still working on my fighting game project and I was wondering how it would be possible to detect, during an animation, on which specific frame of a state the sprite currently is. 

Example: my fighter sprite has 2 states, one being normalState and the other one is attackingState.  When the player hits the attack button, the state changes from normalState to attackingState.  Now, this state is composed of 4 frames.  The thing is, how am I supposed to detect when the attack animation has ended (on the 4th frame) to switch the state back from attackingState to normalState?

Or am I confused and not taking the most logic approach?

Thanks for your help!
Legacy of Kain: Revival completed!
http://lokrevival.webs.com

See also my company website:
http://chivalrousgames.com

Tanja

  • Clever
  • Fanatic
  • ***
  • Posts: 606
    • View Profile
Re: Animation related question
« Reply #1 on: 2008-01-14, 02:02:31 PM »
try this:
make a "if"-rule.
action: >=
left operand: frame
right operand: 3 (because mathematical(?) counting starts at 0, not at 1)

the rule becomes active, when the actual frame of the state is higher-equal 3.
put this rule into your set of switchState-rules.
then you can make a new rule which switches back to normalState.

i think this should work.

Goowolgo

  • Regular
  • **
  • Posts: 21
    • AOL Instant Messenger - CaseyAAdams
    • View Profile
    • Facebook
    • Email
Re: Animation related question
« Reply #2 on: 2008-01-14, 02:07:59 PM »
wow, you beat me to it Morg.  ;D

I do have a question though. In this case would it matter if you used >= or just ==?

Tanja

  • Clever
  • Fanatic
  • ***
  • Posts: 606
    • View Profile
Re: Animation related question
« Reply #3 on: 2008-01-14, 02:27:25 PM »
you can try ==, but as i tried some time, it gave me a big fat error while compiling. i don't know why. try it, anyway.

Vincent

  • SGDK2 Addict
  • Expert
  • Fanatic
  • *****
  • Posts: 612
  • Legacy of Kain: Revival is completed!!!
    • View Profile
    • Chivalrous Games
    • Email
Re: Animation related question
« Reply #4 on: 2008-01-14, 02:28:40 PM »
Great!  :)

It is working just fine!

What I was missing was that I didn't know it was possible to get the actual frame in the left or right operand dropdown list.

Thanks a lot Morgengrauen!
Legacy of Kain: Revival completed!
http://lokrevival.webs.com

See also my company website:
http://chivalrousgames.com

Tanja

  • Clever
  • Fanatic
  • ***
  • Posts: 606
    • View Profile
Re: Animation related question
« Reply #5 on: 2008-01-14, 02:33:30 PM »
you are welcome.  ;)
when you are scripting, try to look often into the dropdown menu for the possible actions. when you got these in mind, it will be a lot easier to create new ideas how to script something.
the possible actions in plans are different from those in the sprite definitions. some things you can only achieve with plan scripts.

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: Animation related question
« Reply #6 on: 2008-01-14, 05:18:09 PM »
If I recall correctly, the "frame" variable indicates how many frames of time have elapsed, and not necessarily how many frames of animation, so be careful about what value you're checking.  If you have 4 frames of animation that each have a repeat count of 5, then you'd probably have to check for a frame value of 20 instead of 4 (or rather 19 instead of 3).  Is your sprite really animated that fast (just 4 frames of time)?  Or am I just losing it; does frame actually represent the animation frame?

Tanja

  • Clever
  • Fanatic
  • ***
  • Posts: 606
    • View Profile
Re: Animation related question
« Reply #7 on: 2008-01-14, 05:27:28 PM »
no blue monk, you are right. it would be frame 19 instead of 3. i forgot to say that.

Vincent

  • SGDK2 Addict
  • Expert
  • Fanatic
  • *****
  • Posts: 612
  • Legacy of Kain: Revival is completed!!!
    • View Profile
    • Chivalrous Games
    • Email
Re: Animation related question
« Reply #8 on: 2008-01-15, 08:18:33 AM »
No problem guys, when I tested the script, I realized that it was going much too fast.  It's definitely frames of time.  And I will keep in mind to look ofter in the dropdown menu! ;)
Legacy of Kain: Revival completed!
http://lokrevival.webs.com

See also my company website:
http://chivalrousgames.com