Return to Snippet

Revision: 26904
at July 8, 2011 06:34 by Monferno


Updated Code
// Requires a Movie Clip with the instance name of 'player'

player.onEnterFrame = function() {	
	if (Key.isDown(Key.LEFT)) {
		player._x = player._x - speed;
		
		speedInc()
	} else if (Key.isDown(Key.RIGHT)) {
		player._x = player._x + speed;
		
		speedInc()
	} else if (Key.isDown(Key.UP)) {
		player._y = player._y - speed;
		
		speedInc()
	} else if (Key.isDown(Key.DOWN)) {
		player._y = player._y + speed;
		
		speedInc()
	} else {
		speed = 5;
	}
}

Revision: 26903
at May 15, 2010 04:02 by Monferno


Initial Code
// Requires a Movie Clip with the instance name of 'player'

player.onEnterFrame = function() {	
	if (Key.isDown(Key.LEFT)) {
		player._x = player._x - speed;
		
		speedInc()
	} else if (Key.isDown(Key.RIGHT)) {
		player._x = player._x + speed;
		
		speedInc()
	} else if (Key.isDown(Key.UP)) {
		player._y = player._y - speed;
		
		speedInc()
	} else if (Key.isDown(Key.DOWN)) {
		player._y = player._y + speed;
		
		speedInc()
	} else {
		speed = 5;
	}
	
	if (player._y == box._y) {
		if (player._x == box._x) {
			trace('crash');
		}
	}
}

Initial URL

                                

Initial Description

                                

Initial Title
Player Movement

Initial Tags

                                

Initial Language
ActionScript