How do i make a character play an animation when they are running and holding space? 2023-12-18 08:06:09
I am trying to make a player change to a running and shooting animation when the spacebar is down and they are moving
onClipEvent (load) {
var ground:MovieClip = _root.ground;
var grav:Number = 0;
var gravity:Number = 2;
var speed:Number = 28;
var maxJump:Number = -24;
var CrouchLeap:Number = 42;
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.LEFT))
{
_xscale = -scale;
_x -= speed;
this.gotoAndStop (2);
}
if (Key.isDown (Key.RIGHT))
{
_xscale = +scale;
_x += speed;
this.gotoAndStop (2);
}
if (Key.isDown (Key.SPACE))
{
this.gotoAndStop (5);
}
if (Key.isDown (Key.UP) && touchingGround)
{
grav = maxJump;
this.gotoAndStop (3);
}
if (Key.isDown (Key.DOWN) && touchingGround)
{
this.gotoAndStop (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;
}
if (_root.vcam.hp._currentframe == 101)
{
speed = 0;
maxJump = 0;
this.gotoAndStop (6);
}
}
onClipEvent (keyUp) {
this.gotoAndStop (1);
}
this is the code, it is in actionscript 2