Sign in to follow this  
Funkymunky

[web] Flash: sprites with multiple animations

Recommended Posts

Alright progressing nicely with my flash learning. I learned how to take a sheet of sprites, put it on a movie clip and use Modify->Break Apart. Then I select the frames I want, and put each frame of the animation on a new keyframe (utilizing onion masking to get them lined up right). Then when I put this movie clip in my scene, it loops through an animation. That's all fine and dandy, but now I want a controllable animated sprite! I want it to have an idle animation, and when I hit a button I want it to change to a different animation. Can anyone point me in the right direction for how to do that?

Share this post


Link to post
Share on other sites
I don't know all the technical details for the action script involved but this is what I do know.

Set up all the animations you need for the sprite on the same timeline. Then give each one a different name. In the scene, the action script will need to call the animations depending on what key is pressed, mouse button clicked etc.

I hope this leads you in the right direction and that others will be able to fill in the technical gaps.

Share this post


Link to post
Share on other sites
I'm somewhat of a novice with Flash, but this is how I would do it. Label the first frame of each animation on the timeline, like "walkRight" "runningLeft" "jumping", etc. Then do something like this:

character.onKeyDown=characterKeyDown;

function characterKeyDown() {
k = Key.getCode();

if(k == RIGHT)
this.goToAndPlay("walkRight");
else if (k == LEFT)
this.goToAndPlay("walkLeft");
}


Make sense? That might not be actual code, but it's basically one way to accomplish it.

Share this post


Link to post
Share on other sites
Quote:
Original post by Brash Benson
I'm somewhat of a novice with Flash, but this is how I would do it. Label the first frame of each animation on the timeline, like "walkRight" "runningLeft" "jumping", etc. Then do something like this:

character.onKeyDown=characterKeyDown;

function characterKeyDown() {
k = Key.getCode();

if(k == RIGHT)
this.goToAndPlay("walkRight");
else if (k == LEFT)
this.goToAndPlay("walkLeft");
}


Make sense? That might not be actual code, but it's basically one way to accomplish it.
Pretty-much. Although you'll need to put some gotoandplay's in the timeline itself to loop through the individual segments, lest your game just loop through all animations.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this