PDA

View Full Version : [AS3] Managing character animation states (yet again)


bloodsample
09-11-2009, 04:54 PM
I've noticed 2 other threads on this topic in the last couple of days. I didn't want to hijack their threads with my own questions so I figured I'd make my own. Hopefully with these 3 threads going we'll all get a better understanding on the subject.

So the issue is managing a character's animation states. Specifically for a platform game. Meaning to transition smoothly from "walking" to "standing" to "shooting a grenade", etc, etc. I understand the basics and I already have a solution for this (albeit very choppy looking). What I want is some advice from more experienced game developers (like yourselves :) ).

Someone in another thread mentioned blitting. As far as I understand it, blitting involves double buffering bitmapData (similar to old sprite engines) correct? I can't use bitmaps because I already have fairly complex motion tweened character animations made.

After trying out a few approaches to this I realized there's 2 main types of character animation states: those that should loop, and those that should be played once and stopped.

The looped ones are pretty easy, I just put the looping MovieClip in one of my frames and then gotoAndStop to that frame when I want it to loop.

The tricky ones (for me at least) are the ones that only play once and stop (eg. throwing a grenade or something). The challenge is to make sure the animation has gone through once before letting the other animations play. For example I want to make sure that the character can't start walking half-way through a grenade throwing animation.

The obvious, and somewhat brute-force method I used to solve this is to either have some kind of flag (boolean) that is set while the animation is played (preventing other animations to play). Or to have an eventListener looking for the end of the animation before letting others go forth (similarly with some flag). This gets fairly complex with a lot of states.

For one of my platform games I had a fairly complex state machine class which controlled the character's states while manually playing back the timeline (with nextFrame(), etc). This gave me a huge headache even with a simple character. Too many combinations and possibilities arose. I think this is overkill. Or is it?

I don't have a specific question but rather I'm looking for some general advice as to what the general approach is for this? I'm glad I'm not the only one with this problem, hopefully someone out there can shed some light on this.

Thanks a lot.

Darksydaz
09-24-2009, 10:15 PM
Actually this is what i'm trying to do... i don't understand this process at all... i made a movieclip with several other movieclips inside of it... and then i played the movie clips with a frame label that has a name. But i try to walk using go to and stop (so it would stop on my specific label and play the one movie clip that i have) and i think it keeps calling the gotoAndStop method so much that it doesn't go through the frames of animation... and that's not a good thing...

but i'm interested in this technique "blitting"... and see what i can find for this... thanks for the help... perhaps i can offer some of what i'm doing in here (i'm creating a platformer in AS3) and help us and others alike...