A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: walking animation problems!!!

  1. #1
    Junior Member
    Join Date
    Nov 2015
    Posts
    6

    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

  2. #2
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    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.

  3. #3
    Junior Member
    Join Date
    Nov 2015
    Posts
    6
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center