Return to stand status after walking


(Pedro Torcatt) #1

The following code makes the character return to its normal state after making the walking animations, I would like to know if it is well implemented or can be improved, thanks, I’m new in the community, Flash Punk is the best.

override public function update():void 
{
Input.define('MOVEMENT', Key.LEFT, Key.RIGHT, Key.UP, Key.DOWN);

if (Input.check('MOVEMENT')){
	if (Input.check(Key.RIGHT))
	{
		x += 100 * FP.elapsed;
		sprSwordguy.play("run");
	}
	
	// Izquierda
	if (Input.check(Key.LEFT))
	{
		x -= 100 * FP.elapsed;
		sprSwordguy.play("run");
	}
	
	//Arriba
	if (Input.check(Key.UP))
	{
		y -= 100 * FP.elapsed;
		sprSwordguy.play("run");
	}
	
	//Abajo
	if (Input.check(Key.DOWN))
	{
		y += 100 * FP.elapsed;
		sprSwordguy.play("run");
	}
}else{
	sprSwordguy.play("stand");
}

I would also like to know how to apply the flipped property in this case.