PDA

View Full Version : Walking Animation


crono7
02-09-2007, 10:34 PM
Well guys, i'm trying to make a site that's basically set up like an RPG, think Zelda or Chrono Trigger. I have a dude, and he can go all over. The problem is i don't know how to make him look like he's walking. I set up a movie clip that moves when the arrow keys are pressed. The mc has 4 frames, each with a picture of the dude facing a different of the 4 directions. When you press a key, the dude faces and moves in that directon. Now, i'm not sure how to have it so that when i hold down the arrow key, the dude walks (moves his legs, i have other pictures of him walking to use) instead of just sliding around. I am really hoping some people have some ideas. i would be incredibly grateful for help and inspiration here!
Thanks, guys.
Crono
P.S. below i wrote part of the relevant code i used so far (only listing the LEFT move. There's more.)


function moveStuff() {
if (Key.isDown(Key.LEFT)) {
this._x -= this.speed;
this.gotoAndPlay(3);
}
}

my_mc.speed = 5;
my_mc.onEnterFrame = movestuff();

Kabomb
02-10-2007, 11:36 PM
Hey.
I'm producing an RPG/platformer at the moment, but I'll show you how to do a simple moving technique (no jumping). Make an MC facing of the character walking right, and place this MC on the main timeline. Then add this code to it:
function movestuff() {
if (Key.isDown(Key.LEFT)) {
this.play();
this._xscale = -100;
this._x -= this.speed;
} else if (Key.isDown(Key.RIGHT)) {
this.play();
this._xscale = 100;
this._x += this.speed;
} else {
this.stop();
}
}
my_mc.speed = 5;
my_mc.onEnterFrame = movestuff();
I'm sure you know what it does, but to everyone else this code makes the xscale = -100 when the left key is down, so he faces left and moves left. If the right key is down, the xscale=100 so he faces right and moves right. And if neither are down, the MC stops and keeps the xscale that it was on.