mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 18:47:35 +00:00
added arrow keys
This commit is contained in:
parent
ae02a9e449
commit
902a7d2056
1 changed files with 29 additions and 7 deletions
|
|
@ -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() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue