Creating Animation Characters

4 posts

Flag Post

Im wondering what the best way to creating a character in a game that has things like this:

1)3 different attacks with one movieclip
2)running
3)walking
4)standing animation (breathing, blinking)

So if i want all this do i create different MCs for every attack and then like make each one visible(not visible) when im doing each of the attack or what? IDK what the best way to do this is. Thanks

 
Flag Post

this is kinda tricky and requires some experimentation on your part but simple put, it works kinda like this.

One: for single frame or ‘frozen’ animations, it’s really simple.

Just make the animation frame in the sprite’s movieclip, make sure you put stop(); in it’s AS field, or when you go to it, use gotoAnd*Stop*(“frame”);

Two: for full looping animations it’s a bit trickier I find.

There’s a couple ways to do this I find, One is to make a flag trigger whenever you Start an animation.

What you would like to do would be say

if (Key.isDown(Key.RIGHT)){
    *move character right here*
    player.gotoAndPlay("walkRight");
}

BUT! unfotunately, all this will do is make the first frame play over and over(if anyone knows better than the following, I’d like to know too!), What I do is this:


    *Code for moving Right here*
    if (walkRightFlag == false){
       walkRightFlag = true;
       player.gotoAndPlay("walkRight");
    }
}//end right key check

So as you can see, if your player isn’t already walking right, it trips the flag to true and starts the walking animation, as long as the flag is true it won’t try to go to the first frame of the animation again, thus allowing your animation to play through and loop as long as the player’s movieClip has the proper goto codes in it TO loop.

example for those who don’t know already:

player movieclip:

frame one: Label: walkRight

frame two: no label, just the next frame of animation

frame three: same as two

frame four: same as two or three, but in the AS code for the frame put gotoAndPlay(“walkRight”);

this will make it loop as long as the game code doesn’t tell it to go to a different animation or pose. It will loop until you tell it to stand still or walkLeft or jump or whatnot, but don’t forget to clear your animation flags when they stop doing whatever they’re animating.

Now, advanced trick that has saved me exponential grief:

Name the frames in your sprite movieClips with some basic convention: What they’re doing and which direction (normalLeft, jumpingRight, shootingDown, etc.) . Now, in your .as files or wherever the body of this sprite’s code is, add these variables:

var isCurrently:String;

var facing:String;

Now, implement them appropriately, whenever the right key is pressed, add your dx code or whatnot and then add changes to the facing, i.e. facing = “Right”;, in addition, make sure you have appropriate arguments for isCurrently as well. If the character is on the ground and you press right, then: isCurrently = “walking”;

now, in whatever bit of code is moving this sprite around, add this:

if(this.isCurrently != "animating"){
     this.gotoAndPlay(this.isCurrently + this.facing);
     if(this.isCurrently == "walking" /*or running or jumping or rolling, etc.*/ ){
          this.isCurrently = "animating";
     }
}

See what I did there? especially if your new to AS, figuring out this tidbit of code will be a brain saver. The game I’m working on currently is a mix of both methods seeing as how I came up with the latter in the process of development, but the former method is pretty glitchy if you’re not careful, the second works pretty faithfully from what I’ve seen so far.

All I can say past this though is that my knowledge is fairly limited, so if there are easier ways to do things(A flipHorizontal(MovieClip); command would be freaking excellent, assuming there is something like that) then I’m sure someone else can provide some better answers, but this is the best I got so far for a 2-D side scroller.

 
Flag Post

ok thx a lot again, this is shank8 on a friend’s account cause i forgot to sign him out but thanks alot

 
Flag Post

I know this is a bit late but I found a cheap trick on the aforementioned flip horizontal/vertical thing.

player._xscale = -100

Found that out while messing with making things bigger/smaller, the scale goes from 1-100 as a percent, but in the negatives, it actually reverses things, so as long as you don’t have something side-sensitive(text, numbers) then you’re good to go, also, YOU could spark the next “is the hero right-handed or left-handed?” debate a la Legend of Zelda.

Hope this helps someone!