added arrow keys

This commit is contained in:
Jeena Paradies 2012-07-10 10:08:55 +02:00
parent ae02a9e449
commit 902a7d2056

View file

@ -13,15 +13,37 @@ define(["Chuck/Control/KeyboardInput"], function(KeyboardInput){
this.KEY_UP = 87; this.KEY_UP = 87;
this.KEY_DOWN = 83; this.KEY_DOWN = 83;
this.init(); var keys = {
w:87,
a:65,
s:83,
d:68,
up: 38,
left: 37,
down: 40,
right: 39
}
this.init(keys);
} }
InputControlUnit.prototype.init = function() { InputControlUnit.prototype.init = function(keys) {
this._keyboardInput.registerKey(this.KEY_LEFT, 'moveLeft', 'stop', 'moveLeft');
this._keyboardInput.registerKey(this.KEY_RIGHT, 'moveRight', 'stop', 'moveRight'); this._keyboardInput.registerKey(keys.a, 'moveLeft', 'stop', 'moveLeft');
this._keyboardInput.registerKey(this.KEY_UP, 'jump', 'jumped', 'jumping'); this._keyboardInput.registerKey(keys.left, 'moveLeft', 'stop', 'moveLeft');
this._keyboardInput.registerKey(this.KEY_DOWN, 'duck', 'standUp', 'duck');
this._keyboardInput.registerKey(this.KEY_DOWN, 'activateShift', 'activateShift', 'deactivateShift'); this._keyboardInput.registerKey(keys.d, 'moveRight', 'stop', 'moveRight');
this._keyboardInput.registerKey(keys.right, 'moveRight', 'stop', 'moveRight');
this._keyboardInput.registerKey(keys.w, 'jump', 'jumped', 'jumping');
this._keyboardInput.registerKey(keys.up, 'jump', 'jumped', 'jumping');
this._keyboardInput.registerKey(keys.s, 'duck', 'standUp', 'duck');
this._keyboardInput.registerKey(keys.down, 'duck', 'standUp', 'duck');
this._keyboardInput.registerKey(keys.s, 'activateShift', 'activateShift', 'deactivateShift');
this._keyboardInput.registerKey(keys.down, 'activateShift', 'activateShift', 'deactivateShift');
} }
InputControlUnit.prototype.moveLeft = function() { InputControlUnit.prototype.moveLeft = function() {