PDA

View Full Version : WSAD Character Movement Question



plablugoo
July 10th, 2010, 11:39 PM
Is there a way to allow the player to control the character with WSAD and the arrow keys in this code?



k.onKeyDown = function() {
target.onEnterFrame = mover;
var k = Key.getCode();
if (k == Key.UP) {
target.yspeed = -3;
target.xspeed = 0;
target.gotoAndStop(2);
} else if (k == Key.LEFT) {
target.yspeed = 0;
target.xspeed = -3;
target.gotoAndStop(2);
} else if (k == Key.DOWN) {
target.xspeed = 0;
target.yspeed = 3;
target.gotoAndStop(2);
} else if (k == Key.RIGHT) {
target.yspeed = 0;
target.xspeed = 3;
target.gotoAndStop(2);
} else if (k == Key.SHIFT) {
target.yspeed = 0;
target.xspeed = 0;
target.gotoAndStop(3);
}
};
Key.addListener(k);

TOdorus
July 11th, 2010, 07:16 AM
Yes (http://www.kongregate.com/games/Kongregate/shootorial-0)

plablugoo
July 11th, 2010, 02:05 PM
lol do you know how?

Osteel
July 11th, 2010, 02:33 PM
The yes was a link, click it. ;)

plablugoo
July 11th, 2010, 08:22 PM
o i c haha