mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 18:47:35 +00:00
fixed input controllerism - fixes #28
This commit is contained in:
parent
a59a258ad6
commit
f5eacb6335
13 changed files with 163 additions and 223 deletions
40
app/Game/Core/Control/PlayerController.js
Executable file
40
app/Game/Core/Control/PlayerController.js
Executable file
|
|
@ -0,0 +1,40 @@
|
|||
define(function () {
|
||||
|
||||
function PlayerController (player) {
|
||||
|
||||
this.player = player;
|
||||
|
||||
this._shift;
|
||||
this._isJumping;
|
||||
this._walkingDirectionStatus = 0;
|
||||
}
|
||||
|
||||
PlayerController.prototype.moveLeft = function () {
|
||||
this.player.move(-1);
|
||||
this._walkingDirectionStatus = -1;
|
||||
}
|
||||
|
||||
PlayerController.prototype.moveRight = function () {
|
||||
this.player.move(1);
|
||||
this._walkingDirectionStatus = 1;
|
||||
}
|
||||
|
||||
PlayerController.prototype.stop = function () {
|
||||
this.player.stop();
|
||||
this._walkingDirectionStatus = 0;
|
||||
}
|
||||
|
||||
PlayerController.prototype.jump = function () {
|
||||
this._isJumping = true;
|
||||
this.player.jump();
|
||||
}
|
||||
|
||||
PlayerController.prototype.update = function () {
|
||||
//console.log(this._walkingDirectionStatus)
|
||||
if(this._walkingDirectionStatus != 0) {
|
||||
this.player.move(this._walkingDirectionStatus);
|
||||
}
|
||||
}
|
||||
|
||||
return PlayerController;
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue