Jump to content
  • Advertisement
Sign in to follow this  
Funkymunky

[web] Flash: sprites with multiple animations

This topic is 4375 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!