I’m coming back to flash game development after almost two years, so I’m a bit rusty and still using AS2
Anyways here is the important section of the code. Its linked to the player_mc and the walkcycle works fine, but instead of having one foot in the air when the key is lifted I want it to go back to idle. Now I know you can set this up so it works immediately, but I would rather have a delay so that movement is more… smooth.
onClipEvent (load) {
//variables
var step:Number = 10;
var attack:Boolean = false;
var stance:Number = 1;
var crouch:Boolean = false;
var moving:Boolean = false;
// load in idle state
this.gotoAndStop('idle');
//timer before stance returned to idle
Pause = function () {
this.gotoAndStop('idle');
clearInterval(stanceTimer);
};
}
onClipEvent (enterFrame) {
//movement
if (!attack) {
if (Key.isDown(Key.RIGHT)) {
this._xscale = 100;
moving = true;
stance = 1;
this._x += step;
this.gotoAndStop('walkcycle');
this.walkcycle.play();
stanceTimer = 10;
} else if (Key.isDown(Key.LEFT)) {
this._xscale = -100;
moving = true;
stance = 0;
this._x -= step;
this.gotoAndStop('walkcycle');
this.walkcycle.play();
stanceTimer = 10;
} else {
this.walkcycle.stop();
//stance swtich back to idle timer
stanceTimer = setInterval(pause, 3000);
}
}
}