Player Jump not resing to stand

2 posts

Flag Post

I have my player set up so that when you press the up button it jumps up and come back down playing the animation but the problem is when it lands it is still in the jump animation pose and does not reset back to the stand pose.

package
{
import flash.display.MovieClip;
import flash.events.Event;
import flash.ui.Keyboard;

public class Player extends MovieClip
{
public var speed:int;
public var dy:Number=0;
public var gravity:Number=1;
public var canjump:Boolean = false;

public function Player()
{
// set the player speed
speed = 10;

addEventListener(“enterFrame”, movePlayer);
}

public function movePlayer(e:Event)
{

// keep the player within the bounds
if(Key.isDown(65) || Key.isDown(Keyboard.LEFT))
{
// face left
this.scaleX = -1;
// walk
if(this.currentLabel != “walk”)
{
this.gotoAndPlay(“walk”);
}
if (this.x > 32)
{
this.x = this.x – speed;
}
else if (this.x < 32) this.x = 32;
}
else if(Key.isDown(68) || Key.isDown(Keyboard.RIGHT))
{

//face right

this.scaleX = 1;
// walk
if(this.currentLabel != “walk”)
{
this.gotoAndPlay(“walk”);
}
if (this.x < 568)
{
this.x = this.x + speed;
}
else if (this.x > 568) this.x = 568;
}
else if(Key.isDown(83) || Key.isDown(Keyboard.DOWN))
{
//crouch
this.gotoAndStop(2);
else
{
//default
this.gotoAndStop(1);
}
dy+=gravity;
if(this.y>300)
{

dy=0;
canjump=true;

}
if(Key.isDown(87) || Key.isDown(Keyboard.UP) && canjump)

{

{
this.gotoAndPlay(4);

}
dy=-10;
canjump=false;
}

this.y+=dy;

}

}
}

 
Flag Post

when your character touches the ground you just need to tell it to go to the stand pose…
if(this.y>300)
{

dy=0;
canjump=true;
this.gotoAndStop(1);//I’m assuming this is your standing pose
}