-
walking animation problems!!!
So
i have this problem
I wanted to make a walking animation but everytime my
char walks it doesn't play the whole animation it just repeats itself to the
first frameprob.JPGprob2.JPGprob3.JPG
onClipEvent (load) {
var ground:MovieClip = _root.ground;
var grav:Number = 0;
var gravity:Number = 2;
var speed:Number = 7;
var maxJump:Number = -30;
var touchingGround:Boolean = false;
scale = _xscale;
}
onClipEvent (enterFrame) {
_y += grav;
grav += gravity;
while (ground.hitTest(_x, _y, true)) {
_y -= gravity;
grav = 0;
}
if (ground.hitTest(_x, _y+5, true)) {
touchingGround = true;
} else {
touchingGround = false;
}
if (Key.isDown(Key.RIGHT)) {
_xscale = +scale;
_x += speed;
this.gotoAndPlay(2);
}
if (Key.isDown(Key.LEFT)) {
_xscale = -scale;
_x -= speed;
this.gotoAndPlay(2);
}
if (Key.isDown(Key.UP) && touchingGround) {
grav = maxJump;
this.gotoAndPlay(3);
}
if (Key.isDown(Key.DOWN)){
this.gotoAndPlay(4);
}
if (ground.hitTest(_x+(_width/2), _y-(_height/2), true)) {
_x -= speed;
}
if (ground.hitTest(_x-(_width/2), _y-(_height/2), true)) {
_x += speed;
}
if (ground.hitTest(_x, _y-(height), true)) {
grav = 3;
}
}
onClipEvent (keyUp) {
this.gotoAndStop(1);
}
this is the script i use
-
.
Hi,
Hard to ascertain without the file infront of us.
You do have it on a clipEvent(enterFrame) so it means it will continually go to frame 2 when going left or right, try using a gotoAndStop(2) also, see what happens.
If that fails try using a listener for you keyboard movement instead.
-
It worked perfectly thanks!!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|