2018-03-13 12:55:11 +01:00
|
|
|
if (!this.entityLoaded) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!this.initialized) {
|
2018-03-13 13:13:23 +01:00
|
|
|
this.direction = this.entityLoaded.direction;
|
2018-03-13 12:55:11 +01:00
|
|
|
this.initialized = true;
|
|
|
|
}
|
|
|
|
|
2018-03-13 13:09:46 +01:00
|
|
|
if (data.keyCode === GameLib.System.Input.KEY_UP) {
|
2018-03-13 13:21:18 +01:00
|
|
|
if (this.direction.y === -1) {
|
|
|
|
return;
|
|
|
|
}
|
2018-03-13 13:13:23 +01:00
|
|
|
this.direction.y = 1;
|
|
|
|
this.direction.x = 0;
|
2018-03-13 13:09:46 +01:00
|
|
|
}
|
|
|
|
|
2018-03-13 13:13:23 +01:00
|
|
|
if (data.keyCode === GameLib.System.Input.KEY_DOWN) {
|
2018-03-13 13:21:18 +01:00
|
|
|
if (this.direction.y === 1) {
|
|
|
|
return;
|
|
|
|
}
|
2018-03-13 13:13:23 +01:00
|
|
|
this.direction.y = -1;
|
|
|
|
this.direction.x = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (data.keyCode === GameLib.System.Input.KEY_LEFT) {
|
2018-03-13 13:21:18 +01:00
|
|
|
if (this.direction.x === 1) {
|
|
|
|
return;
|
|
|
|
}
|
2018-03-13 13:13:23 +01:00
|
|
|
this.direction.y = 0;
|
|
|
|
this.direction.x = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (data.keyCode === GameLib.System.Input.KEY_RIGHT) {
|
2018-03-13 13:21:18 +01:00
|
|
|
if (this.direction.x === -1) {
|
|
|
|
return;
|
|
|
|
}
|
2018-03-13 13:13:23 +01:00
|
|
|
this.direction.y = 0;
|
|
|
|
this.direction.x = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-03-13 12:55:11 +01:00
|
|
|
console.log(data);
|
|
|
|
|
2018-03-13 13:09:46 +01:00
|
|
|
//@ sourceURL=keyUp.js
|