mirror of
https://github.com/photonstorm/phaser
synced 2024-11-28 15:41:37 +00:00
Added lots of the Input Events
This commit is contained in:
parent
078d0c0e1d
commit
01905f0cb6
23 changed files with 561 additions and 36 deletions
|
@ -133,10 +133,10 @@ var InputManager = new Class({
|
|||
this.isOver = true;
|
||||
|
||||
/**
|
||||
* isOver state change property.
|
||||
* The DOM Event that was fired when the canvas dispatched an over or out event.
|
||||
*
|
||||
* @name Phaser.Input.InputManager#_emitIsOverEvent
|
||||
* @type {boolean}
|
||||
* @type {(MouseEvent|TouchEvent)}
|
||||
* @private
|
||||
* @since 3.16.0
|
||||
*/
|
||||
|
@ -413,7 +413,7 @@ var InputManager = new Class({
|
|||
* @private
|
||||
* @since 3.16.0
|
||||
*
|
||||
* @param {number} event - The DOM Event.
|
||||
* @param {(MouseEvent|TouchEvent)} event - The DOM Event.
|
||||
*/
|
||||
setCanvasOver: function (event)
|
||||
{
|
||||
|
@ -429,7 +429,7 @@ var InputManager = new Class({
|
|||
* @private
|
||||
* @since 3.16.0
|
||||
*
|
||||
* @param {number} event - The DOM Event.
|
||||
* @param {(MouseEvent|TouchEvent)} event - The DOM Event.
|
||||
*/
|
||||
setCanvasOut: function (event)
|
||||
{
|
||||
|
|
|
@ -12,6 +12,7 @@ var CreatePixelPerfectHandler = require('./CreatePixelPerfectHandler');
|
|||
var DistanceBetween = require('../math/distance/DistanceBetween');
|
||||
var Ellipse = require('../geom/ellipse/Ellipse');
|
||||
var EllipseContains = require('../geom/ellipse/Contains');
|
||||
var Events = require('./events');
|
||||
var EventEmitter = require('eventemitter3');
|
||||
var GetFastValue = require('../utils/object/GetFastValue');
|
||||
var InputPluginCache = require('./InputPluginCache');
|
||||
|
@ -207,7 +208,7 @@ var InputPlugin = new Class({
|
|||
* Internal event propagation callback container.
|
||||
*
|
||||
* @name Phaser.Input.InputPlugin#_eventContainer
|
||||
* @type {object}
|
||||
* @type {Phaser.Input.EventData}
|
||||
* @private
|
||||
* @since 3.13.0
|
||||
*/
|
||||
|
@ -363,6 +364,7 @@ var InputPlugin = new Class({
|
|||
* Do not invoke it directly.
|
||||
*
|
||||
* @method Phaser.Input.InputPlugin#boot
|
||||
* @fires Phaser.Input.Events#BOOT
|
||||
* @private
|
||||
* @since 3.5.1
|
||||
*/
|
||||
|
@ -375,7 +377,7 @@ var InputPlugin = new Class({
|
|||
this.systems.events.once('destroy', this.destroy, this);
|
||||
|
||||
// Registered input plugins listen for this
|
||||
this.pluginEvents.emit('boot');
|
||||
this.pluginEvents.emit(Events.BOOT);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -384,6 +386,7 @@ var InputPlugin = new Class({
|
|||
* Do not invoke it directly.
|
||||
*
|
||||
* @method Phaser.Input.InputPlugin#start
|
||||
* @fires Phaser.Input.Events#START
|
||||
* @private
|
||||
* @since 3.5.0
|
||||
*/
|
||||
|
@ -405,7 +408,7 @@ var InputPlugin = new Class({
|
|||
this._dragState = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ];
|
||||
|
||||
// Registered input plugins listen for this
|
||||
this.pluginEvents.emit('start');
|
||||
this.pluginEvents.emit(Events.START);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -413,13 +416,14 @@ var InputPlugin = new Class({
|
|||
* deleting old Game Objects.
|
||||
*
|
||||
* @method Phaser.Input.InputPlugin#preUpdate
|
||||
* @fires Phaser.Input.Events#PRE_UPDATE
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*/
|
||||
preUpdate: function ()
|
||||
{
|
||||
// Registered input plugins listen for this
|
||||
this.pluginEvents.emit('preupdate');
|
||||
this.pluginEvents.emit(Events.PRE_UPDATE);
|
||||
|
||||
var removeList = this._pendingRemoval;
|
||||
var insertList = this._pendingInsertion;
|
||||
|
@ -476,6 +480,9 @@ var InputPlugin = new Class({
|
|||
* Called automatically by the Scene Systems step.
|
||||
*
|
||||
* @method Phaser.Input.InputPlugin#update
|
||||
* @fires Phaser.Input.Events#GAME_OUT
|
||||
* @fires Phaser.Input.Events#GAME_OVER
|
||||
* @fires Phaser.Input.Events#UPDATE
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*
|
||||
|
@ -491,7 +498,7 @@ var InputPlugin = new Class({
|
|||
|
||||
var manager = this.manager;
|
||||
|
||||
this.pluginEvents.emit('update', time, delta);
|
||||
this.pluginEvents.emit(Events.UPDATE, time, delta);
|
||||
|
||||
// Another Scene above this one has already consumed the input events, or we're in transition
|
||||
if (manager.globalTopOnly && manager.ignoreEvents)
|
||||
|
@ -501,7 +508,7 @@ var InputPlugin = new Class({
|
|||
|
||||
if (manager._emitIsOverEvent)
|
||||
{
|
||||
var event = (manager.isOver) ? 'gameover' : 'gameout';
|
||||
var event = (manager.isOver) ? Events.GAME_OVER : Events.GAME_OUT;
|
||||
|
||||
this.emit(event, time, manager._emitIsOverEvent);
|
||||
}
|
||||
|
@ -768,10 +775,10 @@ var InputPlugin = new Class({
|
|||
*
|
||||
* @method Phaser.Input.InputPlugin#processDownEvents
|
||||
* @private
|
||||
* @fires Phaser.GameObjects.GameObject#pointerdownEvent
|
||||
* @fires Phaser.Input.InputPlugin#gameobjectdownEvent
|
||||
* @fires Phaser.Input.InputPlugin#pointerdownEvent
|
||||
* @fires Phaser.Input.InputPlugin#pointerdownoutsideEvent
|
||||
* @fires Phaser.Input.Events#GAMEOBJECT_POINTER_DOWN
|
||||
* @fires Phaser.Input.Events#GAMEOBJECT_DOWN
|
||||
* @fires Phaser.Input.Events#POINTER_DOWN
|
||||
* @fires Phaser.Input.Events#POINTER_DOWN_OUTSIDE
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Input.Pointer} pointer - The Pointer being tested.
|
||||
|
@ -802,7 +809,7 @@ var InputPlugin = new Class({
|
|||
|
||||
total++;
|
||||
|
||||
gameObject.emit('pointerdown', pointer, gameObject.input.localX, gameObject.input.localY, _eventContainer);
|
||||
gameObject.emit(Events.GAMEOBJECT_POINTER_DOWN, pointer, gameObject.input.localX, gameObject.input.localY, _eventContainer);
|
||||
|
||||
if (_eventData.cancelled)
|
||||
{
|
||||
|
@ -810,7 +817,7 @@ var InputPlugin = new Class({
|
|||
break;
|
||||
}
|
||||
|
||||
this.emit('gameobjectdown', pointer, gameObject, _eventContainer);
|
||||
this.emit(Events.GAMEOBJECT_DOWN, pointer, gameObject, _eventContainer);
|
||||
|
||||
if (_eventData.cancelled)
|
||||
{
|
||||
|
@ -822,10 +829,14 @@ var InputPlugin = new Class({
|
|||
// If they released outside the canvas, but pressed down inside it, we'll still dispatch the event.
|
||||
if (!aborted)
|
||||
{
|
||||
var type = (pointer.downElement === this.manager.game.canvas) ? 'pointerdown' : 'pointerdownoutside';
|
||||
|
||||
// Contains ALL Game Objects currently up in the array
|
||||
this.emit(type, pointer, currentlyOver);
|
||||
if (pointer.downElement === this.manager.game.canvas)
|
||||
{
|
||||
this.emit(Events.POINTER_DOWN, pointer, currentlyOver);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.emit(Events.POINTER_DOWN_OUTSIDE, pointer);
|
||||
}
|
||||
}
|
||||
|
||||
return total;
|
||||
|
@ -1164,9 +1175,10 @@ var InputPlugin = new Class({
|
|||
* An internal method that handles the Pointer movement event.
|
||||
*
|
||||
* @method Phaser.Input.InputPlugin#processMoveEvents
|
||||
* @fires Phaser.Input.Events#GAMEOBJECT_POINTER_MOVE
|
||||
* @fires Phaser.Input.Events#GAMEOBJECT_MOVE
|
||||
* @fires Phaser.Input.Events#POINTER_MOVE
|
||||
* @private
|
||||
* @fires Phaser.GameObjects.GameObject#pointermoveEvent
|
||||
* @fires Phaser.Input.InputPlugin#gameobjectmoveEvent
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Input.Pointer} pointer - The pointer to check for events against.
|
||||
|
@ -1197,7 +1209,7 @@ var InputPlugin = new Class({
|
|||
|
||||
total++;
|
||||
|
||||
gameObject.emit('pointermove', pointer, gameObject.input.localX, gameObject.input.localY, _eventContainer);
|
||||
gameObject.emit(Events.GAMEOBJECT_POINTER_MOVE, pointer, gameObject.input.localX, gameObject.input.localY, _eventContainer);
|
||||
|
||||
if (_eventData.cancelled)
|
||||
{
|
||||
|
@ -1205,7 +1217,7 @@ var InputPlugin = new Class({
|
|||
break;
|
||||
}
|
||||
|
||||
this.emit('gameobjectmove', pointer, gameObject, _eventContainer);
|
||||
this.emit(Events.GAMEOBJECT_MOVE, pointer, gameObject, _eventContainer);
|
||||
|
||||
if (_eventData.cancelled)
|
||||
{
|
||||
|
@ -1221,7 +1233,7 @@ var InputPlugin = new Class({
|
|||
|
||||
if (!aborted)
|
||||
{
|
||||
this.emit('pointermove', pointer, currentlyOver);
|
||||
this.emit(Events.POINTER_MOVE, pointer, currentlyOver);
|
||||
}
|
||||
|
||||
return total;
|
||||
|
@ -1406,9 +1418,10 @@ var InputPlugin = new Class({
|
|||
*
|
||||
* @method Phaser.Input.InputPlugin#processUpEvents
|
||||
* @private
|
||||
* @fires Phaser.GameObjects.GameObject#pointerupEvent
|
||||
* @fires Phaser.Input.InputPlugin#gameobjectupEvent
|
||||
* @fires Phaser.Input.InputPlugin#gameobjectupoutsideEvent
|
||||
* @fires Phaser.Input.Events#GAMEOBJECT_POINTER_UP
|
||||
* @fires Phaser.Input.Events#GAMEOBJECT_UP
|
||||
* @fires Phaser.Input.Events#POINTER_UP
|
||||
* @fires Phaser.Input.Events#POINTER_UP_OUTSIDE
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Input.Pointer} pointer - The pointer to check for events against.
|
||||
|
@ -1436,7 +1449,7 @@ var InputPlugin = new Class({
|
|||
continue;
|
||||
}
|
||||
|
||||
gameObject.emit('pointerup', pointer, gameObject.input.localX, gameObject.input.localY, _eventContainer);
|
||||
gameObject.emit(Events.GAMEOBJECT_POINTER_UP, pointer, gameObject.input.localX, gameObject.input.localY, _eventContainer);
|
||||
|
||||
if (_eventData.cancelled)
|
||||
{
|
||||
|
@ -1444,7 +1457,7 @@ var InputPlugin = new Class({
|
|||
break;
|
||||
}
|
||||
|
||||
this.emit('gameobjectup', pointer, gameObject, _eventContainer);
|
||||
this.emit(Events.GAMEOBJECT_UP, pointer, gameObject, _eventContainer);
|
||||
|
||||
if (_eventData.cancelled)
|
||||
{
|
||||
|
@ -1456,10 +1469,14 @@ var InputPlugin = new Class({
|
|||
// If they released outside the canvas, but pressed down inside it, we'll still dispatch the event.
|
||||
if (!aborted)
|
||||
{
|
||||
var type = (pointer.upElement === this.manager.game.canvas) ? 'pointerup' : 'pointerupoutside';
|
||||
|
||||
// Contains ALL Game Objects currently up in the array
|
||||
this.emit(type, pointer, currentlyOver);
|
||||
if (pointer.upElement === this.manager.game.canvas)
|
||||
{
|
||||
this.emit(Events.POINTER_UP, pointer, currentlyOver);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.emit(Events.POINTER_UP_OUTSIDE, pointer);
|
||||
}
|
||||
}
|
||||
|
||||
return currentlyOver.length;
|
||||
|
@ -2275,13 +2292,14 @@ var InputPlugin = new Class({
|
|||
* We need to kill and reset all internal properties as well as stop listening to Scene events.
|
||||
*
|
||||
* @method Phaser.Input.InputPlugin#shutdown
|
||||
* @fires Phaser.Input.Events#SHUTDOWN
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*/
|
||||
shutdown: function ()
|
||||
{
|
||||
// Registered input plugins listen for this
|
||||
this.pluginEvents.emit('shutdown');
|
||||
this.pluginEvents.emit(Events.SHUTDOWN);
|
||||
|
||||
this._temp.length = 0;
|
||||
this._list.length = 0;
|
||||
|
@ -2314,6 +2332,7 @@ var InputPlugin = new Class({
|
|||
* We need to shutdown and then kill off all external references.
|
||||
*
|
||||
* @method Phaser.Input.InputPlugin#destroy
|
||||
* @fires Phaser.Input.Events#DESTROY
|
||||
* @private
|
||||
* @since 3.0.0
|
||||
*/
|
||||
|
@ -2322,7 +2341,7 @@ var InputPlugin = new Class({
|
|||
this.shutdown();
|
||||
|
||||
// Registered input plugins listen for this
|
||||
this.pluginEvents.emit('destroy');
|
||||
this.pluginEvents.emit(Events.DESTROY);
|
||||
|
||||
this.pluginEvents.removeAllListeners();
|
||||
|
||||
|
|
14
src/input/events/BOOT_EVENT.js
Normal file
14
src/input/events/BOOT_EVENT.js
Normal file
|
@ -0,0 +1,14 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2019 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Input Plugin Boot Event.
|
||||
*
|
||||
* This internal event is dispatched by the Input Plugin when it boots, signalling to all of its systems to create themselves.
|
||||
*
|
||||
* @event Phaser.Input.Events#BOOT
|
||||
*/
|
||||
module.exports = 'boot';
|
14
src/input/events/DESTROY_EVENT.js
Normal file
14
src/input/events/DESTROY_EVENT.js
Normal file
|
@ -0,0 +1,14 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2019 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Input Plugin Destroy Event.
|
||||
*
|
||||
* This internal event is dispatched by the Input Plugin when it is destroyed, signalling to all of its systems to destroy themselves.
|
||||
*
|
||||
* @event Phaser.Input.Events#DESTROY
|
||||
*/
|
||||
module.exports = 'destroy';
|
34
src/input/events/GAMEOBJECT_DOWN_EVENT.js
Normal file
34
src/input/events/GAMEOBJECT_DOWN_EVENT.js
Normal file
|
@ -0,0 +1,34 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2019 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Game Object Down Input Event.
|
||||
*
|
||||
* This event is dispatched by the Input Plugin belonging to a Scene if a pointer is pressed down on _any_ interactive Game Object.
|
||||
*
|
||||
* Listen to this event from within a Scene using: `this.input.on('gameobjectdown', listener)`.
|
||||
*
|
||||
* To receive this event, the Game Objects must have been set as interactive.
|
||||
* See [GameObject.setInteractive]{Phaser.GameObjects.GameObject#setInteractive} for more details.
|
||||
*
|
||||
* To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_POINTER_DOWN event]{Phaser.Input.Events#GAMEOBJECT_POINTER_DOWN} instead.
|
||||
*
|
||||
* The event hierarchy is as follows:
|
||||
*
|
||||
* 1) GAMEOBJECT_POINTER_DOWN
|
||||
* 2) GAMEOBJECT_DOWN
|
||||
* 3) POINTER_DOWN or POINTER_DOWN_OUTSIDE
|
||||
*
|
||||
* With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop
|
||||
* the propagation of this event.
|
||||
*
|
||||
* @event Phaser.Input.Events#GAMEOBJECT_DOWN
|
||||
*
|
||||
* @param {Phaser.Input.Pointer} pointer - The Pointer responsible for triggering this event.
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object the pointer was pressed down on.
|
||||
* @param {Phaser.Input.EventData} event - The Phaser input event. You can call `stopPropagation()` to halt it from going any further in the event flow.
|
||||
*/
|
||||
module.exports = 'gameobjectdown';
|
34
src/input/events/GAMEOBJECT_MOVE_EVENT.js
Normal file
34
src/input/events/GAMEOBJECT_MOVE_EVENT.js
Normal file
|
@ -0,0 +1,34 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2019 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Game Object Move Input Event.
|
||||
*
|
||||
* This event is dispatched by the Input Plugin belonging to a Scene if a pointer is moved across _any_ interactive Game Object.
|
||||
*
|
||||
* Listen to this event from within a Scene using: `this.input.on('gameobjectmove', listener)`.
|
||||
*
|
||||
* To receive this event, the Game Objects must have been set as interactive.
|
||||
* See [GameObject.setInteractive]{Phaser.GameObjects.GameObject#setInteractive} for more details.
|
||||
*
|
||||
* To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_POINTER_MOVE event]{Phaser.Input.Events#GAMEOBJECT_POINTER_MOVE} instead.
|
||||
*
|
||||
* The event hierarchy is as follows:
|
||||
*
|
||||
* 1) GAMEOBJECT_POINTER_MOVE
|
||||
* 2) GAMEOBJECT_MOVE
|
||||
* 3) POINTER_MOVE
|
||||
*
|
||||
* With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop
|
||||
* the propagation of this event.
|
||||
*
|
||||
* @event Phaser.Input.Events#GAMEOBJECT_MOVE
|
||||
*
|
||||
* @param {Phaser.Input.Pointer} pointer - The Pointer responsible for triggering this event.
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object the pointer was moved on.
|
||||
* @param {Phaser.Input.EventData} event - The Phaser input event. You can call `stopPropagation()` to halt it from going any further in the event flow.
|
||||
*/
|
||||
module.exports = 'gameobjectmove';
|
34
src/input/events/GAMEOBJECT_POINTER_DOWN_EVENT.js
Normal file
34
src/input/events/GAMEOBJECT_POINTER_DOWN_EVENT.js
Normal file
|
@ -0,0 +1,34 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2019 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Game Object Pointer Down Event.
|
||||
*
|
||||
* This event is dispatched by an interactive Game Object if a pointer is pressed down on it.
|
||||
*
|
||||
* Listen to this event from a Game Object using: `gameObject.on('pointerdown', listener)`.
|
||||
* Note that the scope of the listener is automatically set to be the Game Object instance itself.
|
||||
*
|
||||
* To receive this event, the Game Object must have been set as interactive.
|
||||
* See [GameObject.setInteractive]{Phaser.GameObjects.GameObject#setInteractive} for more details.
|
||||
*
|
||||
* The event hierarchy is as follows:
|
||||
*
|
||||
* 1) GAMEOBJECT_POINTER_DOWN
|
||||
* 2) GAMEOBJECT_DOWN
|
||||
* 3) POINTER_DOWN or POINTER_DOWN_OUTSIDE
|
||||
*
|
||||
* With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop
|
||||
* the propagation of this event.
|
||||
*
|
||||
* @event Phaser.Input.Events#GAMEOBJECT_POINTER_DOWN
|
||||
*
|
||||
* @param {Phaser.Input.Pointer} pointer - The Pointer responsible for triggering this event.
|
||||
* @param {number} localX - The x coordinate that the Pointer interacted with this object on, relative to the Game Object's top-left position.
|
||||
* @param {number} localY - The y coordinate that the Pointer interacted with this object on, relative to the Game Object's top-left position.
|
||||
* @param {Phaser.Input.EventData} event - The Phaser input event. You can call `stopPropagation()` to halt it from going any further in the event flow.
|
||||
*/
|
||||
module.exports = 'pointerdown';
|
34
src/input/events/GAMEOBJECT_POINTER_MOVE_EVENT.js
Normal file
34
src/input/events/GAMEOBJECT_POINTER_MOVE_EVENT.js
Normal file
|
@ -0,0 +1,34 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2019 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Game Object Pointer Move Event.
|
||||
*
|
||||
* This event is dispatched by an interactive Game Object if a pointer is moved while over it.
|
||||
*
|
||||
* Listen to this event from a Game Object using: `gameObject.on('pointermove', listener)`.
|
||||
* Note that the scope of the listener is automatically set to be the Game Object instance itself.
|
||||
*
|
||||
* To receive this event, the Game Object must have been set as interactive.
|
||||
* See [GameObject.setInteractive]{Phaser.GameObjects.GameObject#setInteractive} for more details.
|
||||
*
|
||||
* The event hierarchy is as follows:
|
||||
*
|
||||
* 1) GAMEOBJECT_POINTER_MOVE
|
||||
* 2) GAMEOBJECT_MOVE
|
||||
* 3) POINTER_MOVE
|
||||
*
|
||||
* With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop
|
||||
* the propagation of this event.
|
||||
*
|
||||
* @event Phaser.Input.Events#GAMEOBJECT_POINTER_MOVE
|
||||
*
|
||||
* @param {Phaser.Input.Pointer} pointer - The Pointer responsible for triggering this event.
|
||||
* @param {number} localX - The x coordinate that the Pointer interacted with this object on, relative to the Game Object's top-left position.
|
||||
* @param {number} localY - The y coordinate that the Pointer interacted with this object on, relative to the Game Object's top-left position.
|
||||
* @param {Phaser.Input.EventData} event - The Phaser input event. You can call `stopPropagation()` to halt it from going any further in the event flow.
|
||||
*/
|
||||
module.exports = 'pointermove';
|
34
src/input/events/GAMEOBJECT_POINTER_UP_EVENT.js
Normal file
34
src/input/events/GAMEOBJECT_POINTER_UP_EVENT.js
Normal file
|
@ -0,0 +1,34 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2019 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Game Object Pointer Up Event.
|
||||
*
|
||||
* This event is dispatched by an interactive Game Object if a pointer is released while over it.
|
||||
*
|
||||
* Listen to this event from a Game Object using: `gameObject.on('pointerup', listener)`.
|
||||
* Note that the scope of the listener is automatically set to be the Game Object instance itself.
|
||||
*
|
||||
* To receive this event, the Game Object must have been set as interactive.
|
||||
* See [GameObject.setInteractive]{Phaser.GameObjects.GameObject#setInteractive} for more details.
|
||||
*
|
||||
* The event hierarchy is as follows:
|
||||
*
|
||||
* 1) GAMEOBJECT_POINTER_UP
|
||||
* 2) GAMEOBJECT_UP
|
||||
* 3) POINTER_UP or POINTER_UP_OUTSIDE
|
||||
*
|
||||
* With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop
|
||||
* the propagation of this event.
|
||||
*
|
||||
* @event Phaser.Input.Events#GAMEOBJECT_POINTER_UP
|
||||
*
|
||||
* @param {Phaser.Input.Pointer} pointer - The Pointer responsible for triggering this event.
|
||||
* @param {number} localX - The x coordinate that the Pointer interacted with this object on, relative to the Game Object's top-left position.
|
||||
* @param {number} localY - The y coordinate that the Pointer interacted with this object on, relative to the Game Object's top-left position.
|
||||
* @param {Phaser.Input.EventData} event - The Phaser input event. You can call `stopPropagation()` to halt it from going any further in the event flow.
|
||||
*/
|
||||
module.exports = 'pointerup';
|
34
src/input/events/GAMEOBJECT_UP_EVENT.js
Normal file
34
src/input/events/GAMEOBJECT_UP_EVENT.js
Normal file
|
@ -0,0 +1,34 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2019 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Game Object Up Input Event.
|
||||
*
|
||||
* This event is dispatched by the Input Plugin belonging to a Scene if a pointer is released while over _any_ interactive Game Object.
|
||||
*
|
||||
* Listen to this event from within a Scene using: `this.input.on('gameobjectup', listener)`.
|
||||
*
|
||||
* To receive this event, the Game Objects must have been set as interactive.
|
||||
* See [GameObject.setInteractive]{Phaser.GameObjects.GameObject#setInteractive} for more details.
|
||||
*
|
||||
* To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_POINTER_UP event]{Phaser.Input.Events#GAMEOBJECT_POINTER_UP} instead.
|
||||
*
|
||||
* The event hierarchy is as follows:
|
||||
*
|
||||
* 1) GAMEOBJECT_POINTER_UP
|
||||
* 2) GAMEOBJECT_UP
|
||||
* 3) POINTER_UP or POINTER_UP_OUTSIDE
|
||||
*
|
||||
* With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop
|
||||
* the propagation of this event.
|
||||
*
|
||||
* @event Phaser.Input.Events#GAMEOBJECT_UP
|
||||
*
|
||||
* @param {Phaser.Input.Pointer} pointer - The Pointer responsible for triggering this event.
|
||||
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object the pointer was over when released.
|
||||
* @param {Phaser.Input.EventData} event - The Phaser input event. You can call `stopPropagation()` to halt it from going any further in the event flow.
|
||||
*/
|
||||
module.exports = 'gameobjectup';
|
20
src/input/events/GAME_OUT_EVENT.js
Normal file
20
src/input/events/GAME_OUT_EVENT.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2019 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Input Plugin Game Out Event.
|
||||
*
|
||||
* This event is dispatched by the Input Plugin if the active pointer leaves the game canvas and is now
|
||||
* outside of it, elsewhere on the web page.
|
||||
*
|
||||
* Listen to this event from within a Scene using: `this.input.on('gameout', listener)`.
|
||||
*
|
||||
* @event Phaser.Input.Events#GAME_OUT
|
||||
*
|
||||
* @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout.
|
||||
* @param {(MouseEvent|TouchEvent)} event - The DOM Event that triggered the canvas out.
|
||||
*/
|
||||
module.exports = 'gameout';
|
20
src/input/events/GAME_OVER_EVENT.js
Normal file
20
src/input/events/GAME_OVER_EVENT.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2019 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Input Plugin Game Over Event.
|
||||
*
|
||||
* This event is dispatched by the Input Plugin if the active pointer enters the game canvas and is now
|
||||
* over of it, having previously been elsewhere on the web page.
|
||||
*
|
||||
* Listen to this event from within a Scene using: `this.input.on('gameover', listener)`.
|
||||
*
|
||||
* @event Phaser.Input.Events#GAME_OVER
|
||||
*
|
||||
* @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout.
|
||||
* @param {(MouseEvent|TouchEvent)} event - The DOM Event that triggered the canvas over.
|
||||
*/
|
||||
module.exports = 'gameover';
|
28
src/input/events/POINTER_DOWN_EVENT.js
Normal file
28
src/input/events/POINTER_DOWN_EVENT.js
Normal file
|
@ -0,0 +1,28 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2019 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Pointer Down Input Event.
|
||||
*
|
||||
* This event is dispatched by the Input Plugin belonging to a Scene if a pointer is pressed down anywhere.
|
||||
*
|
||||
* Listen to this event from within a Scene using: `this.input.on('pointerdown', listener)`.
|
||||
*
|
||||
* The event hierarchy is as follows:
|
||||
*
|
||||
* 1) GAMEOBJECT_POINTER_DOWN
|
||||
* 2) GAMEOBJECT_DOWN
|
||||
* 3) POINTER_DOWN or POINTER_DOWN_OUTSIDE
|
||||
*
|
||||
* With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop
|
||||
* the propagation of this event.
|
||||
*
|
||||
* @event Phaser.Input.Events#POINTER_DOWN
|
||||
*
|
||||
* @param {Phaser.Input.Pointer} pointer - The Pointer responsible for triggering this event.
|
||||
* @param {Phaser.GameObjects.GameObject[]} currentlyOver - An array containing all interactive Game Objects that the pointer was over when the event was created.
|
||||
*/
|
||||
module.exports = 'pointerdown';
|
27
src/input/events/POINTER_DOWN_OUTSIDE_EVENT.js
Normal file
27
src/input/events/POINTER_DOWN_OUTSIDE_EVENT.js
Normal file
|
@ -0,0 +1,27 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2019 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Pointer Down Outside Input Event.
|
||||
*
|
||||
* This event is dispatched by the Input Plugin belonging to a Scene if a pointer is pressed down anywhere outside of the game canvas.
|
||||
*
|
||||
* Listen to this event from within a Scene using: `this.input.on('pointerdownoutside', listener)`.
|
||||
*
|
||||
* The event hierarchy is as follows:
|
||||
*
|
||||
* 1) GAMEOBJECT_POINTER_DOWN
|
||||
* 2) GAMEOBJECT_DOWN
|
||||
* 3) POINTER_DOWN or POINTER_DOWN_OUTSIDE
|
||||
*
|
||||
* With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop
|
||||
* the propagation of this event.
|
||||
*
|
||||
* @event Phaser.Input.Events#POINTER_DOWN_OUTSIDE
|
||||
*
|
||||
* @param {Phaser.Input.Pointer} pointer - The Pointer responsible for triggering this event.
|
||||
*/
|
||||
module.exports = 'pointerdownoutside';
|
28
src/input/events/POINTER_MOVE_EVENT.js
Normal file
28
src/input/events/POINTER_MOVE_EVENT.js
Normal file
|
@ -0,0 +1,28 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2019 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Pointer Move Input Event.
|
||||
*
|
||||
* This event is dispatched by the Input Plugin belonging to a Scene if a pointer is moved anywhere.
|
||||
*
|
||||
* Listen to this event from within a Scene using: `this.input.on('pointermove', listener)`.
|
||||
*
|
||||
* The event hierarchy is as follows:
|
||||
*
|
||||
* 1) GAMEOBJECT_POINTER_MOVE
|
||||
* 2) GAMEOBJECT_MOVE
|
||||
* 3) POINTER_MOVE
|
||||
*
|
||||
* With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop
|
||||
* the propagation of this event.
|
||||
*
|
||||
* @event Phaser.Input.Events#POINTER_MOVE
|
||||
*
|
||||
* @param {Phaser.Input.Pointer} pointer - The Pointer responsible for triggering this event.
|
||||
* @param {Phaser.GameObjects.GameObject[]} currentlyOver - An array containing all interactive Game Objects that the pointer was over when the event was created.
|
||||
*/
|
||||
module.exports = 'pointermove';
|
28
src/input/events/POINTER_UP_EVENT.js
Normal file
28
src/input/events/POINTER_UP_EVENT.js
Normal file
|
@ -0,0 +1,28 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2019 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Pointer Up Input Event.
|
||||
*
|
||||
* This event is dispatched by the Input Plugin belonging to a Scene if a pointer is released anywhere.
|
||||
*
|
||||
* Listen to this event from within a Scene using: `this.input.on('pointerup', listener)`.
|
||||
*
|
||||
* The event hierarchy is as follows:
|
||||
*
|
||||
* 1) GAMEOBJECT_POINTER_UP
|
||||
* 2) GAMEOBJECT_UP
|
||||
* 3) POINTER_UP or POINTER_UP_OUTSIDE
|
||||
*
|
||||
* With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop
|
||||
* the propagation of this event.
|
||||
*
|
||||
* @event Phaser.Input.Events#POINTER_UP
|
||||
*
|
||||
* @param {Phaser.Input.Pointer} pointer - The Pointer responsible for triggering this event.
|
||||
* @param {Phaser.GameObjects.GameObject[]} currentlyOver - An array containing all interactive Game Objects that the pointer was over when the event was created.
|
||||
*/
|
||||
module.exports = 'pointerup';
|
27
src/input/events/POINTER_UP_OUTSIDE_EVENT.js
Normal file
27
src/input/events/POINTER_UP_OUTSIDE_EVENT.js
Normal file
|
@ -0,0 +1,27 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2019 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Pointer Up Outside Input Event.
|
||||
*
|
||||
* This event is dispatched by the Input Plugin belonging to a Scene if a pointer is released anywhere outside of the game canvas.
|
||||
*
|
||||
* Listen to this event from within a Scene using: `this.input.on('pointerupoutside', listener)`.
|
||||
*
|
||||
* The event hierarchy is as follows:
|
||||
*
|
||||
* 1) GAMEOBJECT_POINTER_UP
|
||||
* 2) GAMEOBJECT_UP
|
||||
* 3) POINTER_UP or POINTER_UP_OUTSIDE
|
||||
*
|
||||
* With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop
|
||||
* the propagation of this event.
|
||||
*
|
||||
* @event Phaser.Input.Events#POINTER_UP_OUTSIDE
|
||||
*
|
||||
* @param {Phaser.Input.Pointer} pointer - The Pointer responsible for triggering this event.
|
||||
*/
|
||||
module.exports = 'pointerupoutside';
|
15
src/input/events/PRE_UPDATE_EVENT.js
Normal file
15
src/input/events/PRE_UPDATE_EVENT.js
Normal file
|
@ -0,0 +1,15 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2019 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Input Plugin Pre-Update Event.
|
||||
*
|
||||
* This internal event is dispatched by the Input Plugin at the start of its `preUpdate` method.
|
||||
* This hook is designed specifically for input plugins, but can also be listened to from user-land code.
|
||||
*
|
||||
* @event Phaser.Input.Events#PRE_UPDATE
|
||||
*/
|
||||
module.exports = 'preupdate';
|
14
src/input/events/SHUTDOWN_EVENT.js
Normal file
14
src/input/events/SHUTDOWN_EVENT.js
Normal file
|
@ -0,0 +1,14 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2019 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Input Plugin Shutdown Event.
|
||||
*
|
||||
* This internal event is dispatched by the Input Plugin when it shuts down, signalling to all of its systems to shut themselves down.
|
||||
*
|
||||
* @event Phaser.Input.Events#SHUTDOWN
|
||||
*/
|
||||
module.exports = 'shutdown';
|
15
src/input/events/START_EVENT.js
Normal file
15
src/input/events/START_EVENT.js
Normal file
|
@ -0,0 +1,15 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2019 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Input Plugin Start Event.
|
||||
*
|
||||
* This internal event is dispatched by the Input Plugin when it has finished setting-up,
|
||||
* signalling to all of its internal systems to start.
|
||||
*
|
||||
* @event Phaser.Input.Events#START
|
||||
*/
|
||||
module.exports = 'start';
|
18
src/input/events/UPDATE_EVENT.js
Normal file
18
src/input/events/UPDATE_EVENT.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2019 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Input Plugin Update Event.
|
||||
*
|
||||
* This internal event is dispatched by the Input Plugin at the start of its `update` method.
|
||||
* This hook is designed specifically for input plugins, but can also be listened to from user-land code.
|
||||
*
|
||||
* @event Phaser.Input.Events#UPDATE
|
||||
*
|
||||
* @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout.
|
||||
* @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate.
|
||||
*/
|
||||
module.exports = 'update';
|
33
src/input/events/index.js
Normal file
33
src/input/events/index.js
Normal file
|
@ -0,0 +1,33 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2019 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @namespace Phaser.Input.Events
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
|
||||
BOOT: require('./BOOT_EVENT'),
|
||||
DESTROY: require('./DESTROY_EVENT'),
|
||||
GAME_OUT: require('./GAME_OUT_EVENT'),
|
||||
GAME_OVER: require('./GAME_OVER_EVENT'),
|
||||
GAMEOBJECT_DOWN: require('./GAMEOBJECT_DOWN_EVENT'),
|
||||
GAMEOBJECT_MOVE: require('./GAMEOBJECT_MOVE_EVENT'),
|
||||
GAMEOBJECT_POINTER_DOWN: require('./GAMEOBJECT_POINTER_DOWN_EVENT'),
|
||||
GAMEOBJECT_POINTER_MOVE: require('./GAMEOBJECT_POINTER_MOVE_EVENT'),
|
||||
GAMEOBJECT_POINTER_UP: require('./GAMEOBJECT_POINTER_UP_EVENT'),
|
||||
GAMEOBJECT_UP: require('./GAMEOBJECT_UP_EVENT'),
|
||||
POINTER_DOWN: require('./POINTER_DOWN_EVENT'),
|
||||
POINTER_DOWN_OUTSIDE: require('./POINTER_DOWN_OUTSIDE_EVENT'),
|
||||
POINTER_MOVE: require('./POINTER_MOVE_EVENT'),
|
||||
POINTER_UP: require('./POINTER_UP_EVENT'),
|
||||
POINTER_UP_OUTSIDE: require('./POINTER_UP_OUTSIDE_EVENT'),
|
||||
PRE_UPDATE: require('./PRE_UPDATE_EVENT'),
|
||||
SHUTDOWN: require('./SHUTDOWN_EVENT'),
|
||||
START: require('./START_EVENT'),
|
||||
UPDATE: require('./UPDATE_EVENT')
|
||||
|
||||
};
|
|
@ -14,6 +14,7 @@ var Extend = require('../utils/object/Extend');
|
|||
var Input = {
|
||||
|
||||
CreateInteractiveObject: require('./CreateInteractiveObject'),
|
||||
Events: require('./events'),
|
||||
Gamepad: require('./gamepad'),
|
||||
InputManager: require('./InputManager'),
|
||||
InputPlugin: require('./InputPlugin'),
|
||||
|
|
Loading…
Reference in a new issue