mirror of
https://github.com/wassname/phaser.git
synced 2026-08-09 12:20:34 +08:00
New Input handler implemented.
This commit is contained in:
@@ -15,7 +15,6 @@ module Phaser {
|
||||
constructor(game: Game) {
|
||||
|
||||
this._game = game;
|
||||
this.start();
|
||||
|
||||
}
|
||||
|
||||
@@ -23,6 +22,12 @@ module Phaser {
|
||||
private _keys = {};
|
||||
private _capture = {};
|
||||
|
||||
/**
|
||||
* You can disable all Input by setting disabled = true. While set all new input related events will be ignored.
|
||||
* @type {Boolean}
|
||||
*/
|
||||
public disabled: bool = false;
|
||||
|
||||
public start() {
|
||||
|
||||
document.body.addEventListener('keydown', (event: KeyboardEvent) => this.onKeyDown(event), false);
|
||||
@@ -69,6 +74,11 @@ module Phaser {
|
||||
*/
|
||||
public onKeyDown(event: KeyboardEvent) {
|
||||
|
||||
if (this._game.input.disabled || this.disabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (this._capture[event.keyCode])
|
||||
{
|
||||
event.preventDefault();
|
||||
@@ -91,6 +101,11 @@ module Phaser {
|
||||
*/
|
||||
public onKeyUp(event: KeyboardEvent) {
|
||||
|
||||
if (this._game.input.disabled || this.disabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (this._capture[event.keyCode])
|
||||
{
|
||||
event.preventDefault();
|
||||
|
||||
Reference in New Issue
Block a user