mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
fixes #32
This commit is contained in:
parent
2c5bb1bb39
commit
1e748a93cb
5 changed files with 6 additions and 42 deletions
|
|
@ -8,7 +8,6 @@ function (http, nodeStatic) {
|
||||||
function HttpServer (options) {
|
function HttpServer (options) {
|
||||||
options.port = options.port || 1234;
|
options.port = options.port || 1234;
|
||||||
options.caching = typeof options.caching != 'undefined' ? options.caching : 3600;
|
options.caching = typeof options.caching != 'undefined' ? options.caching : 3600;
|
||||||
console.log(options.caching)
|
|
||||||
options.rootDirectory = options.rootDirectory || './';
|
options.rootDirectory = options.rootDirectory || './';
|
||||||
|
|
||||||
this.server = null;
|
this.server = null;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@
|
||||||
this._activityUpdateNeeded = false;
|
this._activityUpdateNeeded = false;
|
||||||
this._keyDownFunction = null;
|
this._keyDownFunction = null;
|
||||||
this._keyUpFunction = null;
|
this._keyUpFunction = null;
|
||||||
this._keyFrameFunction = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Key.prototype.setActivityUpdateStatus = function (active) {
|
Key.prototype.setActivityUpdateStatus = function (active) {
|
||||||
|
|
@ -49,13 +48,5 @@
|
||||||
return this._keyUpFunction;
|
return this._keyUpFunction;
|
||||||
}
|
}
|
||||||
|
|
||||||
Key.prototype.setKeyFrameFunction = function (f) {
|
|
||||||
this._keyFrameFunction = f;
|
|
||||||
}
|
|
||||||
|
|
||||||
Key.prototype.getKeyFrameFunction = function () {
|
|
||||||
return this._keyFrameFunction;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Key;
|
return Key;
|
||||||
});
|
});
|
||||||
|
|
@ -18,11 +18,10 @@ function (Key) {
|
||||||
window.onkeyup = this._onKeyUp.bind(this);
|
window.onkeyup = this._onKeyUp.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyboardInput.prototype.registerKey = function (keyCode, onKeyDown, onKeyUp, onKeyFrame) {
|
KeyboardInput.prototype.registerKey = function (keyCode, onKeyDown, onKeyUp) {
|
||||||
var key = new Key();
|
var key = new Key();
|
||||||
if(onKeyDown) key.setKeyDownFunction(onKeyDown);
|
if(onKeyDown) key.setKeyDownFunction(onKeyDown);
|
||||||
if(onKeyUp) key.setKeyUpFunction(onKeyUp);
|
if(onKeyUp) key.setKeyUpFunction(onKeyUp);
|
||||||
if(onKeyFrame) key.setKeyFrameFunction(onKeyFrame);
|
|
||||||
this._registry[keyCode] = key;
|
this._registry[keyCode] = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -49,25 +48,5 @@ function (Key) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* If KeyFrameFunction was set, it is executed when key is active
|
|
||||||
*/
|
|
||||||
KeyboardInput.prototype.update = function () {
|
|
||||||
var callback = null;
|
|
||||||
|
|
||||||
for (var keyCode in this._registry) {
|
|
||||||
var key = this._getKeyByKeyCode(keyCode);
|
|
||||||
|
|
||||||
if (key.getActive()) {
|
|
||||||
callback = key.getKeyFrameFunction();
|
|
||||||
if (callback) {
|
|
||||||
this._playerController[callback]();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
callback = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return KeyboardInput;
|
return KeyboardInput;
|
||||||
});
|
});
|
||||||
|
|
@ -26,7 +26,9 @@ function (Parent, KeyboardInput, MouseInput, NotificationCenter) {
|
||||||
up: 38,
|
up: 38,
|
||||||
left: 37,
|
left: 37,
|
||||||
down: 40,
|
down: 40,
|
||||||
right: 39
|
right: 39,
|
||||||
|
|
||||||
|
space: 32
|
||||||
}
|
}
|
||||||
|
|
||||||
this.init(keys);
|
this.init(keys);
|
||||||
|
|
@ -44,6 +46,7 @@ function (Parent, KeyboardInput, MouseInput, NotificationCenter) {
|
||||||
|
|
||||||
this.keyboardInput.registerKey(keys.w, 'jump');
|
this.keyboardInput.registerKey(keys.w, 'jump');
|
||||||
this.keyboardInput.registerKey(keys.up, 'jump');
|
this.keyboardInput.registerKey(keys.up, 'jump');
|
||||||
|
this.keyboardInput.registerKey(keys.space, 'jump');
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerController.prototype.moveLeft = function () {
|
PlayerController.prototype.moveLeft = function () {
|
||||||
|
|
@ -77,13 +80,7 @@ function (Parent, KeyboardInput, MouseInput, NotificationCenter) {
|
||||||
Parent.prototype.handAction.call(this, options);
|
Parent.prototype.handAction.call(this, options);
|
||||||
NotificationCenter.trigger("sendGameCommand", "handAction", options);
|
NotificationCenter.trigger("sendGameCommand", "handAction", options);
|
||||||
};
|
};
|
||||||
|
|
||||||
PlayerController.prototype.update = function () {
|
|
||||||
this.keyboardInput.update();
|
|
||||||
Parent.prototype.update.call(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return PlayerController;
|
return PlayerController;
|
||||||
});
|
});
|
||||||
|
|
@ -130,8 +130,6 @@ function (Parent, DomController, PIXI, Settings, NotificationCenter) {
|
||||||
};
|
};
|
||||||
|
|
||||||
PixiView.prototype.setCameraZoom = function (z) {
|
PixiView.prototype.setCameraZoom = function (z) {
|
||||||
//this.container.position.x = x;
|
|
||||||
//this.container.position.y = y;
|
|
||||||
this.container.scale.x = z;
|
this.container.scale.x = z;
|
||||||
this.container.scale.y = z;
|
this.container.scale.y = z;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue