Skip to content

Commit c3ab9dd

Browse files
committed
Added Input Manager events
1 parent e4902e3 commit c3ab9dd

5 files changed

Lines changed: 54 additions & 3 deletions

File tree

src/input/InputManager.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
var Class = require('../utils/Class');
88
var CONST = require('./const');
99
var EventEmitter = require('eventemitter3');
10+
var Events = require('./events');
1011
var Keyboard = require('./keyboard/KeyboardManager');
1112
var Mouse = require('./mouse/MouseManager');
1213
var Pointer = require('./Pointer');
@@ -391,6 +392,7 @@ var InputManager = new Class({
391392
*
392393
* @method Phaser.Input.InputManager#boot
393394
* @protected
395+
* @fires Phaser.Input.Events#MANAGER_BOOT
394396
* @since 3.0.0
395397
*/
396398
boot: function ()
@@ -399,7 +401,7 @@ var InputManager = new Class({
399401

400402
this.scaleManager = this.game.scale;
401403

402-
this.events.emit('boot');
404+
this.events.emit(Events.MANAGER_BOOT);
403405

404406
this.game.events.on('prestep', this.update, this);
405407
this.game.events.on('poststep', this.postUpdate, this);
@@ -443,6 +445,7 @@ var InputManager = new Class({
443445
*
444446
* @method Phaser.Input.InputManager#update
445447
* @private
448+
* @fires Phaser.Input.Events#MANAGER_UPDATE
446449
* @since 3.0.0
447450
*
448451
* @param {number} time - The time stamp value of this game step.
@@ -453,7 +456,7 @@ var InputManager = new Class({
453456

454457
this._setCursor = 0;
455458

456-
this.events.emit('update');
459+
this.events.emit(Events.MANAGER_UPDATE);
457460

458461
this.ignoreEvents = false;
459462

@@ -522,7 +525,7 @@ var InputManager = new Class({
522525
break;
523526

524527
case CONST.POINTER_LOCK_CHANGE:
525-
this.events.emit('pointerlockchange', event, this.mouse.locked);
528+
this.events.emit(Events.POINTERLOCK_CHANGE, event, this.mouse.locked);
526529
break;
527530
}
528531
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* @author Richard Davey <rich@photonstorm.com>
3+
* @copyright 2019 Photon Storm Ltd.
4+
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
5+
*/
6+
7+
/**
8+
* The Input Manager Boot Event.
9+
*
10+
* This internal event is dispatched by the Input Manager when it boots.
11+
*
12+
* @event Phaser.Input.Events#MANAGER_BOOT
13+
*/
14+
module.exports = 'boot';
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* @author Richard Davey <rich@photonstorm.com>
3+
* @copyright 2019 Photon Storm Ltd.
4+
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
5+
*/
6+
7+
/**
8+
* The Input Manager Update Event.
9+
*
10+
* This internal event is dispatched by the Input Manager as part of its update step.
11+
*
12+
* @event Phaser.Input.Events#MANAGER_UPDATE
13+
*/
14+
module.exports = 'update';
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* @author Richard Davey <rich@photonstorm.com>
3+
* @copyright 2019 Photon Storm Ltd.
4+
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
5+
*/
6+
7+
/**
8+
* The Input Manager Pointer Lock Change Event.
9+
*
10+
* This event is dispatched by the Input Manager when it is processing a native Pointer Lock Change DOM Event.
11+
*
12+
* @event Phaser.Input.Events#POINTERLOCK_CHANGE
13+
*
14+
* @param {Event} event - The native DOM Event.
15+
* @param {boolean} locked - The locked state of the Mouse Pointer.
16+
*/
17+
module.exports = 'pointerlockchange';

src/input/events/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,16 @@ module.exports = {
3838
GAMEOBJECT_POINTER_OVER: require('./GAMEOBJECT_POINTER_OVER_EVENT'),
3939
GAMEOBJECT_POINTER_UP: require('./GAMEOBJECT_POINTER_UP_EVENT'),
4040
GAMEOBJECT_UP: require('./GAMEOBJECT_UP_EVENT'),
41+
MANAGER_BOOT: require('./MANAGER_BOOT_EVENT'),
42+
MANAGER_UPDATE: require('./MANAGER_UPDATE_EVENT'),
4143
POINTER_DOWN: require('./POINTER_DOWN_EVENT'),
4244
POINTER_DOWN_OUTSIDE: require('./POINTER_DOWN_OUTSIDE_EVENT'),
4345
POINTER_MOVE: require('./POINTER_MOVE_EVENT'),
4446
POINTER_OUT: require('./POINTER_OUT_EVENT'),
4547
POINTER_OVER: require('./POINTER_OVER_EVENT'),
4648
POINTER_UP: require('./POINTER_UP_EVENT'),
4749
POINTER_UP_OUTSIDE: require('./POINTER_UP_OUTSIDE_EVENT'),
50+
POINTERLOCK_CHANGE: require('./POINTERLOCK_CHANGE_EVENT'),
4851
PRE_UPDATE: require('./PRE_UPDATE_EVENT'),
4952
SHUTDOWN: require('./SHUTDOWN_EVENT'),
5053
START: require('./START_EVENT'),

0 commit comments

Comments
 (0)