diff --git a/src/animations/manager/events/AddAnimationEvent.js b/src/animations/manager/events/AddAnimationEvent.js deleted file mode 100644 index f1c06a603..000000000 --- a/src/animations/manager/events/AddAnimationEvent.js +++ /dev/null @@ -1,29 +0,0 @@ -var Class = require('../../../utils/Class'); -var Event = require('../../../events/Event'); - -var AddAnimationEvent = new Class({ - - Extends: Event, - - initialize: - - /** - * [description] - * - * @event AddAnimationEvent - * @type {Phaser.Event} - * - * @param {string} key - [description] - * @param {Phaser.Animations.Animation} animation - [description] - */ - function AddAnimationEvent (key, animation) - { - Event.call(this, 'ADD_ANIMATION_EVENT'); - - this.key = key; - this.animation = animation; - } - -}); - -module.exports = AddAnimationEvent; diff --git a/src/animations/manager/events/PauseAllAnimationEvent.js b/src/animations/manager/events/PauseAllAnimationEvent.js deleted file mode 100644 index f0380d272..000000000 --- a/src/animations/manager/events/PauseAllAnimationEvent.js +++ /dev/null @@ -1,23 +0,0 @@ -var Class = require('../../../utils/Class'); -var Event = require('../../../events/Event'); - -var PauseAllAnimationEvent = new Class({ - - Extends: Event, - - initialize: - - /** - * [description] - * - * @event PauseAllAnimationEvent - * @type {Phaser.Event} - */ - function PauseAllAnimationEvent () - { - Event.call(this, 'PAUSE_ALL_ANIMATION_EVENT'); - } - -}); - -module.exports = PauseAllAnimationEvent; diff --git a/src/animations/manager/events/RemoveAnimationEvent.js b/src/animations/manager/events/RemoveAnimationEvent.js deleted file mode 100644 index 98e050eca..000000000 --- a/src/animations/manager/events/RemoveAnimationEvent.js +++ /dev/null @@ -1,29 +0,0 @@ -var Class = require('../../../utils/Class'); -var Event = require('../../../events/Event'); - -var RemoveAnimationEvent = new Class({ - - Extends: Event, - - initialize: - - /** - * [description] - * - * @event RemoveAnimationEvent - * @type {Phaser.Event} - * - * @param {string} key - [description] - * @param {Phaser.Animations.Animation} animation - [description] - */ - function RemoveAnimationEvent (key, animation) - { - Event.call(this, 'REMOVE_ANIMATION_EVENT'); - - this.key = key; - this.animation = animation; - } - -}); - -module.exports = RemoveAnimationEvent; diff --git a/src/animations/manager/events/ResumeAllAnimationEvent.js b/src/animations/manager/events/ResumeAllAnimationEvent.js deleted file mode 100644 index e61c9559e..000000000 --- a/src/animations/manager/events/ResumeAllAnimationEvent.js +++ /dev/null @@ -1,23 +0,0 @@ -var Class = require('../../../utils/Class'); -var Event = require('../../../events/Event'); - -var ResumeAllAnimationEvent = new Class({ - - Extends: Event, - - initialize: - - /** - * [description] - * - * @event ResumeAllAnimationEvent - * @type {Phaser.Event} - */ - function ResumeAllAnimationEvent () - { - Event.call(this, 'RESUME_ALL_ANIMATION_EVENT'); - } - -}); - -module.exports = ResumeAllAnimationEvent; diff --git a/src/animations/manager/events/index.js b/src/animations/manager/events/index.js deleted file mode 100644 index 56653595d..000000000 --- a/src/animations/manager/events/index.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = { - ADD_ANIMATION_EVENT: require('./AddAnimationEvent'), - PAUSE_ALL_ANIMATION_EVENT: require('./PauseAllAnimationEvent'), - REMOVE_ANIMATION_EVENT: require('./RemoveAnimationEvent'), - RESUME_ALL_ANIMATION_EVENT: require('./ResumeAllAnimationEvent') -}; diff --git a/src/cache/events/CacheAddEvent.js b/src/cache/events/CacheAddEvent.js deleted file mode 100644 index 4fac0cf39..000000000 --- a/src/cache/events/CacheAddEvent.js +++ /dev/null @@ -1,31 +0,0 @@ -var Class = require('../../utils/Class'); -var Event = require('../../events/Event'); - -var CacheAddEvent = new Class({ - - Extends: Event, - - initialize: - - /** - * [description] - * - * @event CacheAddEvent - * @type {Phaser.Event} - * - * @param {Phaser.Cache.BaseCache} cache - [description] - * @param {string} key - [description] - * @param {any} data - [description] - */ - function CacheAddEvent (cache, key, data) - { - Event.call(this, 'CACHE_ADD_EVENT'); - - this.cache = cache; - this.key = key; - this.data = data; - } - -}); - -module.exports = CacheAddEvent; diff --git a/src/cache/events/CacheRemoveEvent.js b/src/cache/events/CacheRemoveEvent.js deleted file mode 100644 index 0f60eb6da..000000000 --- a/src/cache/events/CacheRemoveEvent.js +++ /dev/null @@ -1,31 +0,0 @@ -var Class = require('../../utils/Class'); -var Event = require('../../events/Event'); - -var CacheRemoveEvent = new Class({ - - Extends: Event, - - initialize: - - /** - * [description] - * - * @event CacheRemoveEvent - * @type {Phaser.Event} - * - * @param {Phaser.Cache.BaseCache} cache - [description] - * @param {string} key - [description] - * @param {any} data - [description] - */ - function CacheRemoveEvent (cache, key, data) - { - Event.call(this, 'CACHE_REMOVE_EVENT'); - - this.cache = cache; - this.key = key; - this.data = data; - } - -}); - -module.exports = CacheRemoveEvent; diff --git a/src/cache/events/index.js b/src/cache/events/index.js deleted file mode 100644 index dd193e365..000000000 --- a/src/cache/events/index.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = { - - CACHE_ADD_EVENT: require('./CacheAddEvent'), - CACHE_REMOVE_EVENT: require('./CacheRemoveEvent') - -}; diff --git a/src/data/Data.js b/src/data/Data.js index 79e030dd2..fc5cfdb8f 100644 --- a/src/data/Data.js +++ b/src/data/Data.js @@ -1,5 +1,4 @@ var Class = require('../utils/Class'); -var Event = require('../events/Event'); var EventEmitter = require('eventemitter3'); /** @@ -10,11 +9,11 @@ var Data = new Class({ initialize: - function Data (parent, eventDispatcher) + function Data (parent, eventEmitter) { this.parent = parent; - this.events = (eventDispatcher) ? eventDispatcher : new EventEmitter(); + this.events = (eventEmitter) ? eventEmitter : new EventEmitter(); this.list = {}; diff --git a/src/events/Event.js b/src/events/Event.js deleted file mode 100644 index 8e26fbe33..000000000 --- a/src/events/Event.js +++ /dev/null @@ -1,31 +0,0 @@ -var Class = require('../utils/Class'); - -var Event = new Class({ - - initialize: - - function Event (type) - { - this.type = type; - - // The element that initiated the event. - this.target; - - this._propagate = true; - }, - - reset: function (target) - { - this.target = target; - - this._propagate = true; - }, - - stopPropagation: function () - { - this._propagate = false; - } - -}); - -module.exports = Event; diff --git a/src/events/EventBinding.js b/src/events/EventBinding.js deleted file mode 100644 index bab308ca6..000000000 --- a/src/events/EventBinding.js +++ /dev/null @@ -1,274 +0,0 @@ -var Class = require('../utils/Class'); -var CONST = require('./const'); -var EventListener = require('./EventListener'); - -var EventBinding = new Class({ - - initialize: - - function EventBinding (dispatcher, type) - { - this.dispatcher = dispatcher; - this.type = type; - this.state = CONST.DISPATCHER_IDLE; - this.active = []; - }, - - total: function () - { - var total = 0; - - for (var i = 0; i < this.active.length; i++) - { - if (this.active[i].state !== CONST.LISTENER_REMOVING) - { - total++; - } - } - - return total; - }, - - get: function (callback) - { - for (var i = 0; i < this.active.length; i++) - { - if (this.active[i].callback === callback) - { - return this.active[i]; - } - } - }, - - getIndex: function (callback) - { - for (var i = 0; i < this.active.length; i++) - { - if (this.active[i].callback === callback) - { - return i; - } - } - - return null; - }, - - has: function (callback) - { - return (this.get(callback)); - }, - - // Called by EventDispatcher.on and EventDispatcher.once - add: function (callback, priority, scope, once) - { - // EventListener - var listener = this.get(callback); - - if (!listener) - { - // The listener doesn't exist, so create one - listener = EventListener(this.type, callback, scope, priority, once); - } - else - { - // Listener already exists, abort - return; - } - - if (this.state === CONST.DISPATCHER_IDLE) - { - // The Dispatcher isn't doing anything, so we don't need a pending state - listener.state = CONST.LISTENER_ACTIVE; - - this.active.push(listener); - - this.active.sort(this.sortHandler); - } - else if (this.state === CONST.DISPATCHER_DISPATCHING) - { - // Add it to the list, but keep the state as pending. - // The call to 'tidy' will sort it out at the end of the dispatch. - this.active.push(listener); - } - }, - - sortHandler: function (listenerA, listenerB) - { - if (listenerB.priority < listenerA.priority) - { - return -1; - } - else if (listenerB.priority > listenerA.priority) - { - return 1; - } - else - { - return 0; - } - }, - - remove: function (callback) - { - if (this.state === CONST.DISPATCHER_IDLE) - { - // The Dispatcher isn't doing anything, so we can remove right away - var i = this.getIndex(callback); - - if (i !== null) - { - this.active.splice(i, 1); - } - } - else if (this.state === CONST.DISPATCHER_DISPATCHING) - { - // The Dispatcher is working, so we flag the listener for removal at the end - var listener = this.get(callback); - - if (listener) - { - listener.state = CONST.LISTENER_REMOVING; - } - } - }, - - dispatch: function (event) - { - if (this.state !== CONST.DISPATCHER_IDLE) - { - throw new Error('Error: Failed to execute \'EventDispatcher.dispatch\' on \'' + this.type + '\': The event is already being dispatched.'); - } - else if (this.active.length === 0) - { - // This was a valid dispatch call, we just had nothing to do ... - return; - } - - this.state = CONST.DISPATCHER_DISPATCHING; - - var listener; - - for (var i = 0; i < this.active.length; i++) - { - // EventListener - listener = this.active[i]; - - if (listener.state !== CONST.LISTENER_ACTIVE) - { - continue; - } - - // listener.callback.call(this.dispatcher, event); - listener.callback.call(listener.scope, event); - - // Has the callback changed the state of this binding? - if (this.state !== CONST.DISPATCHER_DISPATCHING) - { - // Yup! Let's break out - break; - } - - // Was it a 'once' listener? - if (listener.once) - { - listener.state = CONST.LISTENER_REMOVING; - } - - // Has the event been halted by the callback? - if (!event._propagate) - { - // Break out, a listener has called Event.stopPropagation - break; - } - } - - // Dispatch over, or aborted - if (this.state === CONST.DISPATCHER_REMOVING) - { - this.removeAll(); - - // All done, tidy the list in case there were any pending events added - this.tidy(); - } - else - { - // All done, just purge the list - this.tidy(); - - this.state = CONST.DISPATCHER_IDLE; - } - }, - - // Removes all listeners - // If this is currently being dispatched then don't remove 'pending' listeners - // (i.e. ones that were added during the dispatch), only active ones - removeAll: function () - { - if (this.state === CONST.DISPATCHER_IDLE) - { - this.active.length = 0; - } - else - { - for (var i = this.active.length - 1; i >= 0; i--) - { - if (this.active[i].state !== CONST.LISTENER_PENDING) - { - this.active.pop(); - } - } - - this.state = CONST.DISPATCHER_IDLE; - } - }, - - tidy: function () - { - // Nothing to do ... - if (this.active.length === 0) - { - return; - } - - var added = 0; - - var i = this.active.length - 1; - - do - { - if (this.active[i].state === CONST.LISTENER_REMOVING) - { - this.active.splice(i, 1); - } - else if (this.active[i].state === CONST.LISTENER_PENDING) - { - this.active[i].state = CONST.LISTENER_ACTIVE; - added++; - } - - i--; - } - while (i >= 0); - - if (added > 0) - { - this.active.sort(this.sortHandler); - } - }, - - destroy: function () - { - delete this.dispatcher.bindings[this.type]; - - this.active.length = 0; - - this.dispatcher = null; - - this.type = ''; - - this.state = CONST.DISPATCHER_DESTROYED; - } - -}); - -module.exports = EventBinding; diff --git a/src/events/EventDispatcher.js b/src/events/EventDispatcher.js deleted file mode 100644 index 4db1b974d..000000000 --- a/src/events/EventDispatcher.js +++ /dev/null @@ -1,241 +0,0 @@ -var Class = require('../utils/Class'); -var CONST = require('./const'); -var EventBinding = require('./EventBinding'); - -var EventDispatcher = new Class({ - - initialize: - - function EventDispatcher () - { - this.bindings = {}; - this.filters = []; - this.hasFilters = false; - }, - - getBinding: function (type) - { - if (this.bindings.hasOwnProperty(type)) - { - return this.bindings[type]; - } - }, - - createBinding: function (type) - { - if (!this.getBinding(type)) - { - this.bindings[type] = new EventBinding(this, type); - } - - return this.bindings[type]; - }, - - on: function (type, listener, priority, scope) - { - if (priority === undefined) { priority = 0; } - if (scope === undefined) { scope = this; } - - var binding = this.createBinding(type); - - if (binding) - { - binding.add(listener, priority, scope, false); - } - - return this; - }, - - once: function (type, listener, priority, scope) - { - if (priority === undefined) { priority = 0; } - if (scope === undefined) { scope = this; } - - var binding = this.createBinding(type); - - if (binding) - { - binding.add(listener, priority, scope, true); - } - - return this; - }, - - // Add a callback that is notified every time this EventDispatcher dispatches an event - // no matter what the event type is. Filters are invoked first, before any bindings, - // and can stop events if they wish (in which case they'll never reach the bindings) - filter: function (callback) - { - var i = this.filters.indexOf(callback); - - if (i === -1) - { - // Add the filter - this.filters.push(callback); - } - else - { - // Remove the filter - this.filters.splice(i, 1); - } - - this.hasFilters = (this.filters.length > 0); - - return this; - }, - - has: function (type, listener) - { - var binding = this.getBinding(type); - - if (binding) - { - return binding.has(listener); - } - else - { - return false; - } - }, - - total: function (type) - { - var binding = this.getBinding(type); - - if (binding) - { - return binding.total(); - } - }, - - // Removes an event listener. - // If there is no matching listener registered with the EventDispatcher, a call to this method has no effect. - off: function (type, listener) - { - var binding = this.getBinding(type); - - if (binding) - { - binding.remove(listener); - } - - return this; - }, - - _dispatchHandler: function (event) - { - event.reset(this); - - // Pass the event through the filters first - - if (this.hasFilters) - { - for (var i = 0; i < this.filters.length; i++) - { - this.filters[i].call(this, event); - - // Did the filter kill the event? If so, we can abort now - if (!event._propagate) - { - return; - } - } - } - - var binding = this.getBinding(event.type); - - if (binding) - { - binding.dispatch(event); - } - }, - - dispatch: function (event) - { - if (Array.isArray(event)) - { - for (var i = 0; i < event.length; i++) - { - this._dispatchHandler(event[i]); - } - } - else - { - this._dispatchHandler(event); - } - }, - - // Removes all listeners, but retains the event type entries - removeAll: function (type) - { - var binding = this.getBinding(type); - - if (binding) - { - binding.removeAll(); - } - - return this; - }, - - removeAllListeners: function (type) - { - var binding = this.getBinding(type); - - if (binding) - { - binding.removeAll(); - } - - return this; - }, - - removeAllFilters: function () - { - this.filters.length = 0; - - this.hasFilters = false; - - return this; - }, - - delete: function (type) - { - var binding = this.getBinding(type); - - if (binding) - { - if (binding.state === CONST.DISPATCHER_IDLE) - { - binding.destroy(); - - delete this.bindings[type]; - } - else - { - binding.state = CONST.DISPATCHER_DESTROYED; - } - } - - return this; - }, - - deleteAll: function () - { - for (var binding in this.bindings) - { - this.bindings[binding].destroy(); - } - - this.bindings = {}; - }, - - destroy: function () - { - this.deleteAll(); - this.removeAllFilters(); - } - -}); - -module.exports = EventDispatcher; diff --git a/src/events/EventEmitter.js b/src/events/EventEmitter.js new file mode 100644 index 000000000..fed867cc9 --- /dev/null +++ b/src/events/EventEmitter.js @@ -0,0 +1,19 @@ +var Class = require('../utils/Class'); +var EE = require('eventemitter3'); + +// Phaser.EventEmitter + +var EventEmitter = new Class({ + + Extends: EE, + + initialize: + + function EventEmitter () + { + EE.call(this); + } + +}); + +module.exports = EventEmitter; diff --git a/src/events/EventListener.js b/src/events/EventListener.js deleted file mode 100644 index 006d4b6e9..000000000 --- a/src/events/EventListener.js +++ /dev/null @@ -1,15 +0,0 @@ -var CONST = require('./const'); - -var EventListener = function (type, callback, scope, priority, once) -{ - return { - type: type, - callback: callback, - scope: scope, - priority: priority, - once: once, - state: CONST.LISTENER_PENDING - }; -}; - -module.exports = EventListener; diff --git a/src/events/const.js b/src/events/const.js deleted file mode 100644 index eb7b27db7..000000000 --- a/src/events/const.js +++ /dev/null @@ -1,14 +0,0 @@ -var EVENT_CONST = { - - DISPATCHER_IDLE: 0, - DISPATCHER_DISPATCHING: 1, - DISPATCHER_REMOVING: 2, - DISPATCHER_DESTROYED: 3, - - LISTENER_PENDING: 4, - LISTENER_ACTIVE: 5, - LISTENER_REMOVING: 6 - -}; - -module.exports = EVENT_CONST; diff --git a/src/input/gamepad/Axis.js b/src/input/gamepad/Axis.js index 9bb0b01cd..9803ae03e 100644 --- a/src/input/gamepad/Axis.js +++ b/src/input/gamepad/Axis.js @@ -1,7 +1,6 @@ // Phaser.Input.Gamepad.Axis var Class = require('../../utils/Class'); -var GamepadEvent = require('./events/'); var Axis = new Class({ @@ -36,7 +35,7 @@ var Axis = new Class({ percentage = 0; } - return percentage * (this.value > 0 ? 1 : -1); + return percentage * (this.value > 0 ? 1 : -1); } }); diff --git a/src/input/gamepad/Gamepad.js b/src/input/gamepad/Gamepad.js index 1a566a589..711b0681f 100644 --- a/src/input/gamepad/Gamepad.js +++ b/src/input/gamepad/Gamepad.js @@ -3,7 +3,6 @@ var Axis = require('./Axis'); var Button = require('./Button'); var Class = require('../../utils/Class'); -var GamepadEvent = require('./events/'); var Gamepad = new Class({ diff --git a/src/input/gamepad/events/GamepadConnectedEvent.js b/src/input/gamepad/events/GamepadConnectedEvent.js deleted file mode 100644 index bc8caadf3..000000000 --- a/src/input/gamepad/events/GamepadConnectedEvent.js +++ /dev/null @@ -1,21 +0,0 @@ -var Class = require('../../../utils/Class'); -var Event = require('../../../events/Event'); - -var GamepadConnectedEvent = new Class({ - - Extends: Event, - - initialize: - - function GamepadConnectedEvent (gamepad, nativeEvent) - { - Event.call(this, 'GAMEPAD_CONNECTED_EVENT'); - - this.data = nativeEvent; - - this.gamepad = gamepad; - } - -}); - -module.exports = GamepadConnectedEvent; diff --git a/src/input/gamepad/events/GamepadDisconnectedEvent.js b/src/input/gamepad/events/GamepadDisconnectedEvent.js deleted file mode 100644 index 476248fa7..000000000 --- a/src/input/gamepad/events/GamepadDisconnectedEvent.js +++ /dev/null @@ -1,21 +0,0 @@ -var Class = require('../../../utils/Class'); -var Event = require('../../../events/Event'); - -var GamepadDisconnectedEvent = new Class({ - - Extends: Event, - - initialize: - - function GamepadDisconnectedEvent (gamepad, nativeEvent) - { - Event.call(this, 'GAMEPAD_DISCONNECTED_EVENT'); - - this.data = nativeEvent; - - this.gamepad = gamepad; - } - -}); - -module.exports = GamepadDisconnectedEvent; diff --git a/src/input/gamepad/events/GamepadDownEvent.js b/src/input/gamepad/events/GamepadDownEvent.js deleted file mode 100644 index 8e5317a12..000000000 --- a/src/input/gamepad/events/GamepadDownEvent.js +++ /dev/null @@ -1,23 +0,0 @@ -var Class = require('../../../utils/Class'); -var Event = require('../../../events/Event'); - -var GamepadDownEvent = new Class({ - - Extends: Event, - - initialize: - - function GamepadDownEvent (gamepad, button, value, nativeEvent) - { - Event.call(this, 'GAMEPAD_DOWN_EVENT'); - - this.data = nativeEvent; - - this.gamepad = gamepad; - this.button = button; - this.value = value; - } - -}); - -module.exports = GamepadDownEvent; diff --git a/src/input/gamepad/events/GamepadUpEvent.js b/src/input/gamepad/events/GamepadUpEvent.js deleted file mode 100644 index cad0c64e7..000000000 --- a/src/input/gamepad/events/GamepadUpEvent.js +++ /dev/null @@ -1,23 +0,0 @@ -var Class = require('../../../utils/Class'); -var Event = require('../../../events/Event'); - -var GamepadUpEvent = new Class({ - - Extends: Event, - - initialize: - - function GamepadUpEvent (gamepad, button, value, nativeEvent) - { - Event.call(this, 'GAMEPAD_UP_EVENT'); - - this.data = nativeEvent; - - this.gamepad = gamepad; - this.button = button; - this.value = value; - } - -}); - -module.exports = GamepadUpEvent; diff --git a/src/input/gamepad/events/index.js b/src/input/gamepad/events/index.js deleted file mode 100644 index 0402d3cf2..000000000 --- a/src/input/gamepad/events/index.js +++ /dev/null @@ -1,8 +0,0 @@ -// Phaser.Input.Gamepad.Events - -module.exports = { - CONNECTED: require('./GamepadConnectedEvent'), - DISCONNECTED: require('./GamepadDisconnectedEvent'), - DOWN: require('./GamepadDownEvent'), - UP: require('./GamepadUpEvent') -}; diff --git a/src/input/global/GlobalInputManager.js b/src/input/global/GlobalInputManager.js index c1e989c15..0b8f368b1 100644 --- a/src/input/global/GlobalInputManager.js +++ b/src/input/global/GlobalInputManager.js @@ -6,7 +6,6 @@ var Gamepad = require('../gamepad/GamepadManager'); var HitTest = require('./inc/HitTest'); var Keyboard = require('../keyboard/KeyboardManager'); var Mouse = require('../mouse/MouseManager'); -var MouseEvent = require('../mouse/events/'); var Pointer = require('../Pointer'); var Touch = require('../touch/TouchManager'); diff --git a/src/input/keyboard/combo/KeyCombo.js b/src/input/keyboard/combo/KeyCombo.js index 811388378..b5a36b2e7 100644 --- a/src/input/keyboard/combo/KeyCombo.js +++ b/src/input/keyboard/combo/KeyCombo.js @@ -1,6 +1,5 @@ var Class = require('../../../utils/Class'); var GetFastValue = require('../../../utils/object/GetFastValue'); -var KeyComboMatchEvent = require('./KeyComboMatchEvent'); var ProcessKeyCombo = require('./ProcessKeyCombo'); var ResetKeyCombo = require('./ResetKeyCombo'); diff --git a/src/input/keyboard/combo/KeyComboMatchEvent.js b/src/input/keyboard/combo/KeyComboMatchEvent.js deleted file mode 100644 index a8661dce9..000000000 --- a/src/input/keyboard/combo/KeyComboMatchEvent.js +++ /dev/null @@ -1,19 +0,0 @@ -var Class = require('../../../utils/Class'); -var Event = require('../../../events/Event'); - -var KeyComboMatchEvent = new Class({ - - Extends: Event, - - initialize: - - function KeyComboMatchEvent (keyCombo, keyboardEvent) - { - Event.call(this, 'KEY_COMBO_MATCH_EVENT'); - - this.data = keyCombo; - } - -}); - -module.exports = KeyComboMatchEvent; diff --git a/src/input/keyboard/events/KeyDownEvent.js b/src/input/keyboard/events/KeyDownEvent.js deleted file mode 100644 index 3d8b3e6ba..000000000 --- a/src/input/keyboard/events/KeyDownEvent.js +++ /dev/null @@ -1,19 +0,0 @@ -var Class = require('../../../utils/Class'); -var Event = require('../../../events/Event'); - -var KeyDownEvent = new Class({ - - Extends: Event, - - initialize: - - function KeyDownEvent (keyboardEvent) - { - Event.call(this, 'KEY_DOWN_EVENT'); - - this.data = keyboardEvent; - } - -}); - -module.exports = KeyDownEvent; diff --git a/src/input/keyboard/events/KeyUpEvent.js b/src/input/keyboard/events/KeyUpEvent.js deleted file mode 100644 index aa40f5e62..000000000 --- a/src/input/keyboard/events/KeyUpEvent.js +++ /dev/null @@ -1,19 +0,0 @@ -var Class = require('../../../utils/Class'); -var Event = require('../../../events/Event'); - -var KeyUpEvent = new Class({ - - Extends: Event, - - initialize: - - function KeyUpEvent (keyboardEvent) - { - Event.call(this, 'KEY_UP_EVENT'); - - this.data = keyboardEvent; - } - -}); - -module.exports = KeyUpEvent; diff --git a/src/input/keyboard/events/index.js b/src/input/keyboard/events/index.js deleted file mode 100644 index a06dede68..000000000 --- a/src/input/keyboard/events/index.js +++ /dev/null @@ -1,43 +0,0 @@ -var Event = require('../../../events/Event'); -var KeyCodes = require('./../keys/KeyCodes'); - -var events = { - KEY_DOWN_EVENT: require('./KeyDownEvent'), - KEY_UP_EVENT: require('./KeyUpEvent'), - _UP: [], - _DOWN: [] -}; - -function createKeyEvent (type) -{ - var KeyEvent = function (keyboardEvent) - { - Event.call(this, type); - - this.data = keyboardEvent; - }; - - KeyEvent.prototype = Object.create(Event.prototype); - KeyEvent.prototype.constructor = KeyEvent; - - return KeyEvent; -} - -// Inject the KeyCode events - -for (var code in KeyCodes) -{ - // The Key Down Event Types - - var downType = 'KEY_DOWN_' + code; - var upType = 'KEY_UP_' + code; - - events._DOWN[KeyCodes[code]] = createKeyEvent(downType); - events._UP[KeyCodes[code]] = createKeyEvent(upType); - - // More friendly aliases to the main events - events[downType] = events._DOWN[KeyCodes[code]]; - events[upType] = events._UP[KeyCodes[code]]; -} - -module.exports = events; diff --git a/src/input/local/events/DragEndEvent.js b/src/input/local/events/DragEndEvent.js deleted file mode 100644 index 40efc8b63..000000000 --- a/src/input/local/events/DragEndEvent.js +++ /dev/null @@ -1,39 +0,0 @@ -var Class = require('../../../utils/Class'); -var Event = require('../../../events/Event'); - -var DragEndEvent = new Class({ - - Extends: Event, - - initialize: - - function DragEndEvent (pointer, gameObject, dropped) - { - Event.call(this, 'DRAG_END_EVENT'); - - // The Pointer that triggered the event - this.pointer = pointer; - - // The native DOM event (MouseEvent, TouchEvent, etc) - this.event = pointer.event; - - // The Game Object the event occurred on - this.gameObject = gameObject; - - // The camera on which the input event occurred - this.camera = pointer.camera; - - // The local x/y coordinates of the event within the Game Object - this.x = pointer.x; - this.y = pointer.y; - - // When the drag ended did it fire a successful DROP event first? - this.dropped = dropped; - - this.dragX = gameObject.input.dragX; - this.dragY = gameObject.input.dragY; - } - -}); - -module.exports = DragEndEvent; diff --git a/src/input/local/events/DragEnterEvent.js b/src/input/local/events/DragEnterEvent.js deleted file mode 100644 index 4c1fb3c26..000000000 --- a/src/input/local/events/DragEnterEvent.js +++ /dev/null @@ -1,32 +0,0 @@ -var Class = require('../../../utils/Class'); -var Event = require('../../../events/Event'); - -var DragEnterEvent = new Class({ - - Extends: Event, - - initialize: - - function DragEnterEvent (pointer, gameObject, dropZone) - { - Event.call(this, 'DRAG_ENTER_EVENT'); - - // The Pointer that triggered the event - this.pointer = pointer; - - // The native DOM event (MouseEvent, TouchEvent, etc) - this.event = pointer.event; - - // The Game Object the event occurred on - this.gameObject = gameObject; - - // The camera on which the input event occurred - this.camera = pointer.camera; - - // The drop zone the game object was dropped on - this.dropZone = dropZone; - } - -}); - -module.exports = DragEnterEvent; diff --git a/src/input/local/events/DragEvent.js b/src/input/local/events/DragEvent.js deleted file mode 100644 index aa747d513..000000000 --- a/src/input/local/events/DragEvent.js +++ /dev/null @@ -1,37 +0,0 @@ -var Class = require('../../../utils/Class'); -var Event = require('../../../events/Event'); - -var DragEvent = new Class({ - - Extends: Event, - - initialize: - - function DragEvent (pointer, gameObject) - { - Event.call(this, 'DRAG_EVENT'); - - // The Pointer that triggered the event - this.pointer = pointer; - - // The native DOM event (MouseEvent, TouchEvent, etc) - this.event = pointer.event; - - // The Game Object the event occurred on - this.gameObject = gameObject; - - // The camera on which the input event occurred - this.camera = pointer.camera; - - // The local x/y coordinates of the event within the Game Object - this.x = pointer.x; - this.y = pointer.y; - - // The local x/y coordinates of the event within the Game Object - this.dragX = pointer.x - gameObject.input.dragX; - this.dragY = pointer.y - gameObject.input.dragY; - } - -}); - -module.exports = DragEvent; diff --git a/src/input/local/events/DragLeaveEvent.js b/src/input/local/events/DragLeaveEvent.js deleted file mode 100644 index 306ec4e9f..000000000 --- a/src/input/local/events/DragLeaveEvent.js +++ /dev/null @@ -1,32 +0,0 @@ -var Class = require('../../../utils/Class'); -var Event = require('../../../events/Event'); - -var DragLeaveEvent = new Class({ - - Extends: Event, - - initialize: - - function DragLeaveEvent (pointer, gameObject, dropZone) - { - Event.call(this, 'DRAG_LEAVE_EVENT'); - - // The Pointer that triggered the event - this.pointer = pointer; - - // The native DOM event (MouseEvent, TouchEvent, etc) - this.event = pointer.event; - - // The Game Object the event occurred on - this.gameObject = gameObject; - - // The camera on which the input event occurred - this.camera = pointer.camera; - - // The drop zone the game object was dropped on - this.dropZone = dropZone; - } - -}); - -module.exports = DragLeaveEvent; diff --git a/src/input/local/events/DragOverEvent.js b/src/input/local/events/DragOverEvent.js deleted file mode 100644 index d24582e52..000000000 --- a/src/input/local/events/DragOverEvent.js +++ /dev/null @@ -1,32 +0,0 @@ -var Class = require('../../../utils/Class'); -var Event = require('../../../events/Event'); - -var DragOverEvent = new Class({ - - Extends: Event, - - initialize: - - function DragOverEvent (pointer, gameObject, dropZone) - { - Event.call(this, 'DRAG_OVER_EVENT'); - - // The Pointer that triggered the event - this.pointer = pointer; - - // The native DOM event (MouseEvent, TouchEvent, etc) - this.event = pointer.event; - - // The Game Object the event occurred on - this.gameObject = gameObject; - - // The camera on which the input event occurred - this.camera = pointer.camera; - - // The drop zone the game object was dropped on - this.dropZone = dropZone; - } - -}); - -module.exports = DragOverEvent; diff --git a/src/input/local/events/DragStartEvent.js b/src/input/local/events/DragStartEvent.js deleted file mode 100644 index 0c97a0491..000000000 --- a/src/input/local/events/DragStartEvent.js +++ /dev/null @@ -1,36 +0,0 @@ -var Class = require('../../../utils/Class'); -var Event = require('../../../events/Event'); - -var DragStartEvent = new Class({ - - Extends: Event, - - initialize: - - function DragStartEvent (pointer, gameObject) - { - Event.call(this, 'DRAG_START_EVENT'); - - // The Pointer that triggered the event - this.pointer = pointer; - - // The native DOM event (MouseEvent, TouchEvent, etc) - this.event = pointer.event; - - // The Game Object the event occurred on - this.gameObject = gameObject; - - // The camera on which the input event occurred - this.camera = pointer.camera; - - // The local x/y coordinates of the event within the Game Object - this.x = pointer.x; - this.y = pointer.y; - - this.dragX = gameObject.input.dragX; - this.dragY = gameObject.input.dragY; - } - -}); - -module.exports = DragStartEvent; diff --git a/src/input/local/events/DropEvent.js b/src/input/local/events/DropEvent.js deleted file mode 100644 index c240040f9..000000000 --- a/src/input/local/events/DropEvent.js +++ /dev/null @@ -1,32 +0,0 @@ -var Class = require('../../../utils/Class'); -var Event = require('../../../events/Event'); - -var DropEvent = new Class({ - - Extends: Event, - - initialize: - - function DropEvent (pointer, gameObject, dropZone) - { - Event.call(this, 'DROP_EVENT'); - - // The Pointer that triggered the event - this.pointer = pointer; - - // The native DOM event (MouseEvent, TouchEvent, etc) - this.event = pointer.event; - - // The Game Object the event occurred on - this.gameObject = gameObject; - - // The camera on which the input event occurred - this.camera = pointer.camera; - - // The drop zone the game object was dropped on - this.dropZone = dropZone; - } - -}); - -module.exports = DropEvent; diff --git a/src/input/local/events/GameObjectDownEvent.js b/src/input/local/events/GameObjectDownEvent.js deleted file mode 100644 index a78b7ce11..000000000 --- a/src/input/local/events/GameObjectDownEvent.js +++ /dev/null @@ -1,33 +0,0 @@ -var Class = require('../../../utils/Class'); -var Event = require('../../../events/Event'); - -var GameObjectDownEvent = new Class({ - - Extends: Event, - - initialize: - - function GameObjectDownEvent (pointer, gameObject) - { - Event.call(this, 'GAME_OBJECT_DOWN_EVENT'); - - // The Pointer that triggered the event - this.pointer = pointer; - - // The native DOM event (MouseEvent, TouchEvent, etc) - this.event = pointer.event; - - // The Game Object the event occurred on - this.gameObject = gameObject; - - // The camera on which the input event occurred - this.camera = pointer.camera; - - // The local x/y coordinates of the event within the Game Object - this.x = gameObject.input.localX; - this.y = gameObject.input.localY; - } - -}); - -module.exports = GameObjectDownEvent; diff --git a/src/input/local/events/GameObjectMoveEvent.js b/src/input/local/events/GameObjectMoveEvent.js deleted file mode 100644 index 18cd4c987..000000000 --- a/src/input/local/events/GameObjectMoveEvent.js +++ /dev/null @@ -1,33 +0,0 @@ -var Class = require('../../../utils/Class'); -var Event = require('../../../events/Event'); - -var GameObjectMoveEvent = new Class({ - - Extends: Event, - - initialize: - - function GameObjectMoveEvent (pointer, gameObject) - { - Event.call(this, 'GAME_OBJECT_MOVE_EVENT'); - - // The Pointer that triggered the event - this.pointer = pointer; - - // The native DOM event (MouseEvent, TouchEvent, etc) - this.event = pointer.event; - - // The Game Object the event occurred on - this.gameObject = gameObject; - - // The camera on which the input event occurred - this.camera = pointer.camera; - - // The local x/y coordinates of the event within the Game Object - this.x = gameObject.input.localX; - this.y = gameObject.input.localY; - } - -}); - -module.exports = GameObjectMoveEvent; diff --git a/src/input/local/events/GameObjectOutEvent.js b/src/input/local/events/GameObjectOutEvent.js deleted file mode 100644 index 0074cc54e..000000000 --- a/src/input/local/events/GameObjectOutEvent.js +++ /dev/null @@ -1,29 +0,0 @@ -var Class = require('../../../utils/Class'); -var Event = require('../../../events/Event'); - -var GameObjectOutEvent = new Class({ - - Extends: Event, - - initialize: - - function GameObjectOutEvent (pointer, gameObject) - { - Event.call(this, 'GAME_OBJECT_OUT_EVENT'); - - // The Pointer that triggered the event - this.pointer = pointer; - - // The native DOM event (MouseEvent, TouchEvent, etc) - this.event = pointer.event; - - // The Game Object the event occurred on - this.gameObject = gameObject; - - // The camera on which the input event occurred - this.camera = pointer.camera; - } - -}); - -module.exports = GameObjectOutEvent; diff --git a/src/input/local/events/GameObjectOverEvent.js b/src/input/local/events/GameObjectOverEvent.js deleted file mode 100644 index 98c7b6107..000000000 --- a/src/input/local/events/GameObjectOverEvent.js +++ /dev/null @@ -1,33 +0,0 @@ -var Class = require('../../../utils/Class'); -var Event = require('../../../events/Event'); - -var GameObjectOverEvent = new Class({ - - Extends: Event, - - initialize: - - function GameObjectOverEvent (pointer, gameObject) - { - Event.call(this, 'GAME_OBJECT_OVER_EVENT'); - - // The Pointer that triggered the event - this.pointer = pointer; - - // The native DOM event (MouseEvent, TouchEvent, etc) - this.event = pointer.event; - - // The Game Object the event occurred on - this.gameObject = gameObject; - - // The camera on which the input event occurred - this.camera = pointer.camera; - - // The local x/y coordinates of the event within the Game Object - this.x = gameObject.input.localX; - this.y = gameObject.input.localY; - } - -}); - -module.exports = GameObjectOverEvent; diff --git a/src/input/local/events/GameObjectUpEvent.js b/src/input/local/events/GameObjectUpEvent.js deleted file mode 100644 index eff1279b2..000000000 --- a/src/input/local/events/GameObjectUpEvent.js +++ /dev/null @@ -1,33 +0,0 @@ -var Class = require('../../../utils/Class'); -var Event = require('../../../events/Event'); - -var GameObjectUpEvent = new Class({ - - Extends: Event, - - initialize: - - function GameObjectUpEvent (pointer, gameObject) - { - Event.call(this, 'GAME_OBJECT_UP_EVENT'); - - // The Pointer that triggered the event - this.pointer = pointer; - - // The native DOM event (MouseEvent, TouchEvent, etc) - this.event = pointer.event; - - // The Game Object the event occurred on - this.gameObject = gameObject; - - // The camera on which the input event occurred - this.camera = pointer.camera; - - // The local x/y coordinates of the event within the Game Object - this.x = gameObject.input.localX; - this.y = gameObject.input.localY; - } - -}); - -module.exports = GameObjectUpEvent; diff --git a/src/input/local/events/PointerDownEvent.js b/src/input/local/events/PointerDownEvent.js deleted file mode 100644 index c65b9ef50..000000000 --- a/src/input/local/events/PointerDownEvent.js +++ /dev/null @@ -1,39 +0,0 @@ -var Class = require('../../../utils/Class'); -var Event = require('../../../events/Event'); - -var PointerDownEvent = new Class({ - - Extends: Event, - - initialize: - - function PointerDownEvent (pointer, gameObjects) - { - Event.call(this, 'POINTER_DOWN_EVENT'); - - // The Pointer that triggered the event - this.pointer = pointer; - - // The native DOM event (MouseEvent, TouchEvent, etc) - this.event = pointer.event; - - // The camera on which the input event occurred - this.camera = pointer.camera; - - // The x/y coordinates of the event - this.x = pointer.x; - this.y = pointer.y; - - // An array of all the game objects the pointer event occurred on in display list order. - // Will be empty if no objects were interacted with. - // If populated, the bottom element (list[0]) is the highest object on the display list. - // If InputManager.topOnly is true this array will only contain one element. - this.list = gameObjects; - - // A reference to the top-most object on the display list (same as event.list[0]) - this.gameObject = gameObjects[0]; - } - -}); - -module.exports = PointerDownEvent; diff --git a/src/input/local/events/PointerMoveEvent.js b/src/input/local/events/PointerMoveEvent.js deleted file mode 100644 index 7b9aaafde..000000000 --- a/src/input/local/events/PointerMoveEvent.js +++ /dev/null @@ -1,39 +0,0 @@ -var Class = require('../../../utils/Class'); -var Event = require('../../../events/Event'); - -var PointerMoveEvent = new Class({ - - Extends: Event, - - initialize: - - function PointerMoveEvent (pointer, gameObjects) - { - Event.call(this, 'POINTER_MOVE_EVENT'); - - // The Pointer that triggered the event - this.pointer = pointer; - - // The native DOM event (MouseEvent, TouchEvent, etc) - this.event = pointer.event; - - // The camera on which the input event occurred - this.camera = pointer.camera; - - // The x/y coordinates of the event - this.x = pointer.x; - this.y = pointer.y; - - // An array of all the game objects the pointer event occurred on in display list order. - // Will be empty if no objects were interacted with. - // If populated, the bottom element (list[0]) is the highest object on the display list. - // If InputManager.topOnly is true this array will only contain one element. - this.list = gameObjects; - - // A reference to the top-most object on the display list (also this.list[0]). Undefined if there isn't any. - this.gameObject = gameObjects[0]; - } - -}); - -module.exports = PointerMoveEvent; diff --git a/src/input/local/events/PointerOutEvent.js b/src/input/local/events/PointerOutEvent.js deleted file mode 100644 index 5fd937157..000000000 --- a/src/input/local/events/PointerOutEvent.js +++ /dev/null @@ -1,39 +0,0 @@ -var Class = require('../../../utils/Class'); -var Event = require('../../../events/Event'); - -var PointerOutEvent = new Class({ - - Extends: Event, - - initialize: - - function PointerOutEvent (pointer, gameObjects) - { - Event.call(this, 'POINTER_OUT_EVENT'); - - // The Pointer that triggered the event - this.pointer = pointer; - - // The native DOM event (MouseEvent, TouchEvent, etc) - this.event = pointer.event; - - // The camera on which the input event occurred - this.camera = pointer.camera; - - // The x/y coordinates of the event - this.x = pointer.x; - this.y = pointer.y; - - // An array of all the game objects the pointer event occurred on in display list order. - // Will be undefined if no objects were interacted with. - // If populated, the bottom element (list[0]) is the highest object on the display list. - // If InputManager.topOnly is true this array will only contain one element. - this.list = gameObjects; - - // A reference to the top-most object on the display list (also this.list[0]) - this.gameObject = gameObjects[0]; - } - -}); - -module.exports = PointerOutEvent; diff --git a/src/input/local/events/PointerOverEvent.js b/src/input/local/events/PointerOverEvent.js deleted file mode 100644 index 12de11e02..000000000 --- a/src/input/local/events/PointerOverEvent.js +++ /dev/null @@ -1,39 +0,0 @@ -var Class = require('../../../utils/Class'); -var Event = require('../../../events/Event'); - -var PointerOverEvent = new Class({ - - Extends: Event, - - initialize: - - function PointerOverEvent (pointer, gameObjects) - { - Event.call(this, 'POINTER_OVER_EVENT'); - - // The Pointer that triggered the event - this.pointer = pointer; - - // The native DOM event (MouseEvent, TouchEvent, etc) - this.event = pointer.event; - - // The camera on which the input event occurred - this.camera = pointer.camera; - - // The x/y coordinates of the event - this.x = pointer.x; - this.y = pointer.y; - - // An array of all the game objects the pointer event occurred on in display list order. - // Will be undefined if no objects were interacted with. - // If populated, the bottom element (list[0]) is the highest object on the display list. - // If InputManager.topOnly is true this array will only contain one element. - this.list = gameObjects; - - // A reference to the top-most object on the display list (also this.list[0]) - this.gameObject = gameObjects[0]; - } - -}); - -module.exports = PointerOverEvent; diff --git a/src/input/local/events/PointerUpEvent.js b/src/input/local/events/PointerUpEvent.js deleted file mode 100644 index e5a8ac0cd..000000000 --- a/src/input/local/events/PointerUpEvent.js +++ /dev/null @@ -1,39 +0,0 @@ -var Class = require('../../../utils/Class'); -var Event = require('../../../events/Event'); - -var PointerUpEvent = new Class({ - - Extends: Event, - - initialize: - - function PointerUpEvent (pointer, gameObjects) - { - Event.call(this, 'POINTER_UP_EVENT'); - - // The Pointer that triggered the event - this.pointer = pointer; - - // The native DOM event (MouseEvent, TouchEvent, etc) - this.event = pointer.event; - - // The camera on which the input event occurred - this.camera = pointer.camera; - - // The x/y coordinates of the event - this.x = pointer.x; - this.y = pointer.y; - - // An array of all the game objects the pointer event occurred on in display list order. - // Will be empty if no objects were interacted with. - // If populated, the bottom element (list[0]) is the highest object on the display list. - // If InputManager.topOnly is true this array will only contain one element. - this.list = gameObjects; - - // A reference to the top-most object on the display list (same as event.list[0]) - this.gameObject = gameObjects[0]; - } - -}); - -module.exports = PointerUpEvent; diff --git a/src/input/local/events/index.js b/src/input/local/events/index.js deleted file mode 100644 index 3db929713..000000000 --- a/src/input/local/events/index.js +++ /dev/null @@ -1,25 +0,0 @@ -// Phaser.Input.Events - -module.exports = { - - DRAG: require('./DragEvent'), - DRAG_END: require('./DragEndEvent'), - DRAG_ENTER: require('./DragEnterEvent'), - DRAG_LEAVE: require('./DragLeaveEvent'), - DRAG_OVER: require('./DragOverEvent'), - DRAG_START: require('./DragStartEvent'), - DROP: require('./DropEvent'), - - GAME_OBJECT_DOWN: require('./GameObjectDownEvent'), - GAME_OBJECT_MOVE: require('./GameObjectMoveEvent'), - GAME_OBJECT_OUT: require('./GameObjectOutEvent'), - GAME_OBJECT_OVER: require('./GameObjectOverEvent'), - GAME_OBJECT_UP: require('./GameObjectUpEvent'), - - POINTER_DOWN: require('./PointerDownEvent'), - POINTER_MOVE: require('./PointerMoveEvent'), - POINTER_OUT: require('./PointerOutEvent'), - POINTER_OVER: require('./PointerOverEvent'), - POINTER_UP: require('./PointerUpEvent') - -}; diff --git a/src/input/mouse/MouseManager.js b/src/input/mouse/MouseManager.js index 7011a88c0..fcc913f2f 100644 --- a/src/input/mouse/MouseManager.js +++ b/src/input/mouse/MouseManager.js @@ -1,6 +1,5 @@ var Class = require('../../utils/Class'); var Features = require('../../device/Features'); -var MouseEvents = require('./events'); // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent // https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md diff --git a/src/input/mouse/events/MouseDownEvent.js b/src/input/mouse/events/MouseDownEvent.js deleted file mode 100644 index 6a8921e13..000000000 --- a/src/input/mouse/events/MouseDownEvent.js +++ /dev/null @@ -1,22 +0,0 @@ -var Class = require('../../../utils/Class'); -var Event = require('../../../events/Event'); - -var MouseDownEvent = new Class({ - - Extends: Event, - - initialize: - - function MouseDownEvent (nativeEvent) - { - Event.call(this, 'MOUSE_DOWN_EVENT'); - - this.data = nativeEvent; - - this.x = nativeEvent.clientX; - this.y = nativeEvent.clientY; - } - -}); - -module.exports = MouseDownEvent; diff --git a/src/input/mouse/events/MouseMoveEvent.js b/src/input/mouse/events/MouseMoveEvent.js deleted file mode 100644 index 311d40ae2..000000000 --- a/src/input/mouse/events/MouseMoveEvent.js +++ /dev/null @@ -1,22 +0,0 @@ -var Class = require('../../../utils/Class'); -var Event = require('../../../events/Event'); - -var MouseMoveEvent = new Class({ - - Extends: Event, - - initialize: - - function MouseMoveEvent (nativeEvent) - { - Event.call(this, 'MOUSE_MOVE_EVENT'); - - this.data = nativeEvent; - - this.x = nativeEvent.clientX; - this.y = nativeEvent.clientY; - } - -}); - -module.exports = MouseMoveEvent; diff --git a/src/input/mouse/events/MouseUpEvent.js b/src/input/mouse/events/MouseUpEvent.js deleted file mode 100644 index 7a9f77a7b..000000000 --- a/src/input/mouse/events/MouseUpEvent.js +++ /dev/null @@ -1,22 +0,0 @@ -var Class = require('../../../utils/Class'); -var Event = require('../../../events/Event'); - -var MouseUpEvent = new Class({ - - Extends: Event, - - initialize: - - function MouseUpEvent (nativeEvent) - { - Event.call(this, 'MOUSE_UP_EVENT'); - - this.data = nativeEvent; - - this.x = nativeEvent.clientX; - this.y = nativeEvent.clientY; - } - -}); - -module.exports = MouseUpEvent; diff --git a/src/input/mouse/events/PointerLockChangeEvent.js b/src/input/mouse/events/PointerLockChangeEvent.js deleted file mode 100644 index eef9aa82a..000000000 --- a/src/input/mouse/events/PointerLockChangeEvent.js +++ /dev/null @@ -1,20 +0,0 @@ -var Class = require('../../../utils/Class'); -var Event = require('../../../events/Event'); - -var PointerLockChangeEvent = new Class({ - - Extends: Event, - - initialize: - - function PointerLockChangeEvent (nativeEvent, isPointerLocked) - { - Event.call(this, 'POINTER_LOCK_CHANGE_EVENT'); - - this.data = nativeEvent; - this.isPointerLocked = isPointerLocked; - } - -}); - -module.exports = PointerLockChangeEvent; diff --git a/src/input/mouse/events/index.js b/src/input/mouse/events/index.js deleted file mode 100644 index cf597e0d7..000000000 --- a/src/input/mouse/events/index.js +++ /dev/null @@ -1,8 +0,0 @@ -// Phaser.Input.Mouse.Events - -module.exports = { - DOWN: require('./MouseDownEvent'), - UP: require('./MouseUpEvent'), - MOVE: require('./MouseMoveEvent'), - POINTER_LOCK_CHANGE: require('./PointerLockChangeEvent') -}; diff --git a/src/loader/events/LoaderCompleteEvent.js b/src/loader/events/LoaderCompleteEvent.js deleted file mode 100644 index c731fc00b..000000000 --- a/src/loader/events/LoaderCompleteEvent.js +++ /dev/null @@ -1,19 +0,0 @@ -var Class = require('../../utils/Class'); -var Event = require('../../events/Event'); - -var LoaderCompleteEvent = new Class({ - - Extends: Event, - - initialize: - - function LoaderCompleteEvent (loader) - { - Event.call(this, 'LOADER_COMPLETE_EVENT'); - - this.loader = loader; - } - -}); - -module.exports = LoaderCompleteEvent; diff --git a/src/loader/events/LoaderStartEvent.js b/src/loader/events/LoaderStartEvent.js deleted file mode 100644 index 9971976a7..000000000 --- a/src/loader/events/LoaderStartEvent.js +++ /dev/null @@ -1,19 +0,0 @@ -var Class = require('../../utils/Class'); -var Event = require('../../events/Event'); - -var LoaderStartEvent = new Class({ - - Extends: Event, - - initialize: - - function LoaderStartEvent (loader) - { - Event.call(this, 'LOADER_START_EVENT'); - - this.loader = loader; - } - -}); - -module.exports = LoaderStartEvent; diff --git a/src/loader/events/index.js b/src/loader/events/index.js deleted file mode 100644 index f24a39822..000000000 --- a/src/loader/events/index.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = { - - LOADER_START_EVENT: require('./LoaderStartEvent'), - LOADER_COMPLETE_EVENT: require('./LoaderCompleteEvent') - -}; diff --git a/src/phaser.js b/src/phaser.js index aa869bd73..ba2d464e2 100644 --- a/src/phaser.js +++ b/src/phaser.js @@ -15,6 +15,8 @@ var Phaser = { DOM: require('./dom/'), + EventEmitter: require('./events/EventEmitter'), + Game: require('./boot/Game'), Math: require('./math'), diff --git a/src/physics/arcade/events/ArcadePhysicsCollideEvent.js b/src/physics/arcade/events/ArcadePhysicsCollideEvent.js deleted file mode 100644 index 20501419d..000000000 --- a/src/physics/arcade/events/ArcadePhysicsCollideEvent.js +++ /dev/null @@ -1,25 +0,0 @@ -var Class = require('../../../utils/Class'); -var Event = require('../../../events/Event'); - -var ArcadePhysicsCollideEvent = new Class({ - - Extends: Event, - - initialize: - - function ArcadePhysicsCollideEvent (gameObjectA, gameObjectB) - { - Event.call(this, 'ARCADE_COLLIDE_EVENT'); - - this.gameObjectA = gameObjectA; - - this.gameObjectB = gameObjectB; - - this.bodyA = gameObjectA.body; - - this.bodyB = gameObjectB.body; - } - -}); - -module.exports = ArcadePhysicsCollideEvent; diff --git a/src/physics/arcade/events/ArcadePhysicsOverlapEvent.js b/src/physics/arcade/events/ArcadePhysicsOverlapEvent.js deleted file mode 100644 index e67d1a778..000000000 --- a/src/physics/arcade/events/ArcadePhysicsOverlapEvent.js +++ /dev/null @@ -1,25 +0,0 @@ -var Class = require('../../../utils/Class'); -var Event = require('../../../events/Event'); - -var ArcadePhysicsOverlapEvent = new Class({ - - Extends: Event, - - initialize: - - function ArcadePhysicsOverlapEvent (gameObjectA, gameObjectB) - { - Event.call(this, 'ARCADE_OVERLAP_EVENT'); - - this.gameObjectA = gameObjectA; - - this.gameObjectB = gameObjectB; - - this.bodyA = gameObjectA.body; - - this.bodyB = gameObjectB.body; - } - -}); - -module.exports = ArcadePhysicsOverlapEvent; diff --git a/src/physics/arcade/events/ArcadePhysicsWorldBoundsEvent.js b/src/physics/arcade/events/ArcadePhysicsWorldBoundsEvent.js deleted file mode 100644 index a70d985db..000000000 --- a/src/physics/arcade/events/ArcadePhysicsWorldBoundsEvent.js +++ /dev/null @@ -1,26 +0,0 @@ -var Class = require('../../../utils/Class'); -var Event = require('../../../events/Event'); - -var ArcadePhysicsWorldBoundsEvent = new Class({ - - Extends: Event, - - initialize: - - function ArcadePhysicsWorldBoundsEvent (body) - { - Event.call(this, 'ARCADE_WORLD_BOUNDS_EVENT'); - - this.gameObject = body.gameObject; - - this.body = body; - - this.blockedUp = body.blocked.up; - this.blockedDown = body.blocked.down; - this.blockedLeft = body.blocked.left; - this.blockedRight = body.blocked.right; - } - -}); - -module.exports = ArcadePhysicsWorldBoundsEvent; diff --git a/src/physics/arcade/events/index.js b/src/physics/arcade/events/index.js deleted file mode 100644 index 6ec015e73..000000000 --- a/src/physics/arcade/events/index.js +++ /dev/null @@ -1,9 +0,0 @@ -// Phaser.Physics.ArcadePhysics.Events - -module.exports = { - - OVERLAP: require('./ArcadePhysicsOverlapEvent'), - COLLIDE: require('./ArcadePhysicsCollideEvent'), - WORLD_BOUNDS: require('./ArcadePhysicsWorldBoundsEvent') - -}; diff --git a/src/physics/arcade/inc/CollideSpriteVsTilemapLayer.js b/src/physics/arcade/inc/CollideSpriteVsTilemapLayer.js index 3d379c422..ea113bda9 100644 --- a/src/physics/arcade/inc/CollideSpriteVsTilemapLayer.js +++ b/src/physics/arcade/inc/CollideSpriteVsTilemapLayer.js @@ -34,7 +34,7 @@ var CollideSpriteVsTilemapLayer = function (sprite, tilemapLayer, collideCallbac if (TileIntersectsBody(tileWorldRect, body) && (!processCallback || processCallback.call(callbackContext, sprite, tile)) - && ProcessTileCallbacks(tile) + && ProcessTileCallbacks(tile, sprite) && (overlapOnly || SeparateTile(i, body, tile, tileWorldRect, tilemapLayer, this.TILE_BIAS))) { this._total++; @@ -43,6 +43,15 @@ var CollideSpriteVsTilemapLayer = function (sprite, tilemapLayer, collideCallbac { collideCallback.call(callbackContext, sprite, tile); } + + if (overlapOnly && body.onOverlap) + { + sprite.emit('overlap', body.gameObject, tile, body, null); + } + else if (body.onCollide) + { + sprite.emit('collide', body.gameObject, tile, body, null); + } } } }; diff --git a/src/physics/arcade/inc/Separate.js b/src/physics/arcade/inc/Separate.js index bc3d0a5a5..513efa193 100644 --- a/src/physics/arcade/inc/Separate.js +++ b/src/physics/arcade/inc/Separate.js @@ -87,7 +87,7 @@ var Separate = function (body1, body2, processCallback, callbackContext, overlap } else if (body1.onCollide || body2.onCollide) { - this.emit('overlap', body1.gameObject, body2.gameObject, body1, body2); + this.emit('collide', body1.gameObject, body2.gameObject, body1, body2); } } diff --git a/src/physics/arcade/inc/tilemap/ProcessTileCallbacks.js b/src/physics/arcade/inc/tilemap/ProcessTileCallbacks.js index 7bd983bfa..cc4980a04 100644 --- a/src/physics/arcade/inc/tilemap/ProcessTileCallbacks.js +++ b/src/physics/arcade/inc/tilemap/ProcessTileCallbacks.js @@ -1,20 +1,18 @@ -var ProcessTileCallbacks = function (tile) +var ProcessTileCallbacks = function (tile, sprite) { - return true; + // Tile callbacks take priority over layer level callbacks + if (tile.collisionCallback) + { + return !tile.collisionCallback.call(tile.collisionCallbackContext, sprite, tile); + } + else if (tile.layer.callbacks[tile.index]) + { + return !tile.layer.callbacks[tile.index].callback.call( + tile.layer.callbacks[tile.index].callbackContext, sprite, tile + ); + } - // TODO: port v2 - // // Tilemap & tile callbacks take priority - // // A local callback always takes priority over a layer level callback - // if (tile.collisionCallback && !tile.collisionCallback.call(tile.collisionCallbackContext, body.sprite, tile)) - // { - // // If it returns true then we can carry on, otherwise we should abort. - // return false; - // } - // else if (typeof tile.layer.callbacks !== 'undefined' && tile.layer.callbacks[tile.index] && !tile.layer.callbacks[tile.index].callback.call(tile.layer.callbacks[tile.index].callbackContext, body.sprite, tile)) - // { - // // If it returns true then we can carry on, otherwise we should abort. - // return false; - // } + return true; }; module.exports = ProcessTileCallbacks; diff --git a/src/physics/impact/events/CollideEvent.js b/src/physics/impact/events/CollideEvent.js deleted file mode 100644 index bf9adf9aa..000000000 --- a/src/physics/impact/events/CollideEvent.js +++ /dev/null @@ -1,32 +0,0 @@ -var Class = require('../../../utils/Class'); -var Event = require('../../../events/Event'); - -var CollideEvent = new Class({ - - Extends: Event, - - initialize: - - function CollideEvent (bodyA, bodyB, axis) - { - Event.call(this, 'COLLIDE_EVENT'); - - // The first body involved in the collision] - this.bodyA = bodyA; - - // The second body involved in the collision] - this.bodyB = bodyB; - - // The Game Object associated with bodyA (if any) - this.gameObjectA = bodyA.gameObject; - - // The Game Object associated with bodyB (if any) - this.gameObjectB = bodyB.gameObject; - - // Either 'x' or 'y' - this.axis = axis; - } - -}); - -module.exports = CollideEvent; diff --git a/src/physics/impact/events/index.js b/src/physics/impact/events/index.js deleted file mode 100644 index ba4dfaa84..000000000 --- a/src/physics/impact/events/index.js +++ /dev/null @@ -1,7 +0,0 @@ -// Phaser.Physics.Impact.Events - -module.exports = { - - COLLIDE: require('./CollideEvent') - -}; diff --git a/src/physics/matter-js/World.js b/src/physics/matter-js/World.js index 4858f03bf..a77ad126e 100644 --- a/src/physics/matter-js/World.js +++ b/src/physics/matter-js/World.js @@ -10,22 +10,23 @@ var GetValue = require('../../utils/object/GetValue'); var MatterBody = require('./lib/body/Body'); var MatterEvents = require('./lib/core/Events'); var MatterWorld = require('./lib/body/World'); -var PhysicsEvent = require('./events/'); var World = new Class({ + Extends: EventEmitter, + initialize: function World (scene, config) { + EventEmitter.call(this); + this.scene = scene; this.engine = Engine.create(config); this.localWorld = this.engine.world; - this.events = new EventEmitter(); - var gravity = GetValue(config, 'gravity', null); if (gravity) @@ -87,35 +88,66 @@ var World = new Class({ setEventsProxy: function () { - var localEvents = this.events; + var _this = this; + var engine = this.engine; - MatterEvents.on(this.engine, 'beforeUpdate', function (event) { + MatterEvents.on(engine, 'beforeUpdate', function (event) { - localEvents.dispatch(new PhysicsEvent.BEFORE_UPDATE(event)); + _this.emit('beforeupdate', event); }); - MatterEvents.on(this.engine, 'afterUpdate', function (event) { + MatterEvents.on(engine, 'afterUpdate', function (event) { - localEvents.dispatch(new PhysicsEvent.AFTER_UPDATE(event)); + _this.emit('afterupdate', event); }); - MatterEvents.on(this.engine, 'collisionStart', function (event) { + MatterEvents.on(engine, 'collisionStart', function (event) { - localEvents.dispatch(new PhysicsEvent.COLLISION_START(event.pairs)); + var pairs = event.pairs; + var bodyA; + var bodyB; + + if (pairs.length > 0) + { + bodyA = pairs[0].bodyA; + bodyB = pairs[0].bodyB; + } + + _this.emit('collisionstart', event, bodyA, bodyB); }); - MatterEvents.on(this.engine, 'collisionActive', function (event) { + MatterEvents.on(engine, 'collisionActive', function (event) { - localEvents.dispatch(new PhysicsEvent.COLLISION_ACTIVE(event)); + var pairs = event.pairs; + var bodyA; + var bodyB; + + if (pairs.length > 0) + { + bodyA = pairs[0].bodyA; + bodyB = pairs[0].bodyB; + } + + _this.emit('collisionactive', event, bodyA, bodyB); }); - MatterEvents.on(this.engine, 'collisionEnd', function (event) { + MatterEvents.on(engine, 'collisionEnd', function (event) { - localEvents.dispatch(new PhysicsEvent.COLLISION_END(event)); + var pairs = event.pairs; + var bodyA; + var bodyB; + + if (pairs.length > 0) + { + bodyA = pairs[0].bodyA; + bodyB = pairs[0].bodyB; + } + + _this.emit('collisionend', event, bodyA, bodyB); }); }, diff --git a/src/physics/matter-js/components/Sleep.js b/src/physics/matter-js/components/Sleep.js index e1e367f2e..66bd0bc64 100644 --- a/src/physics/matter-js/components/Sleep.js +++ b/src/physics/matter-js/components/Sleep.js @@ -1,5 +1,4 @@ var MatterEvents = require('../lib/core/Events'); -var PhysicsEvent = require('../events/'); var Sleep = { @@ -24,10 +23,10 @@ var Sleep = { { if (value) { - var worldEvents = this.world.events; + var world = this.world; MatterEvents.on(this.body, 'sleepStart', function (event) { - worldEvents.dispatch(new PhysicsEvent.SLEEP_START(event, this)); + world.emit('sleepstart', event, this); }); } else @@ -42,10 +41,10 @@ var Sleep = { { if (value) { - var worldEvents = this.world.events; + var world = this.world; MatterEvents.on(this.body, 'sleepEnd', function (event) { - worldEvents.dispatch(new PhysicsEvent.SLEEP_END(event, this)); + world.emit('sleepend', event, this); }); } else diff --git a/src/physics/matter-js/events/AfterUpdateEvent.js b/src/physics/matter-js/events/AfterUpdateEvent.js deleted file mode 100644 index e02662ca2..000000000 --- a/src/physics/matter-js/events/AfterUpdateEvent.js +++ /dev/null @@ -1,19 +0,0 @@ -var Class = require('../../../utils/Class'); -var Event = require('../../../events/Event'); - -var AfterUpdateEvent = new Class({ - - Extends: Event, - - initialize: - - function AfterUpdateEvent (event) - { - Event.call(this, 'AFTER_UPDATE_EVENT'); - - this.event = event; - } - -}); - -module.exports = AfterUpdateEvent; diff --git a/src/physics/matter-js/events/BeforeUpdateEvent.js b/src/physics/matter-js/events/BeforeUpdateEvent.js deleted file mode 100644 index 89732fe2f..000000000 --- a/src/physics/matter-js/events/BeforeUpdateEvent.js +++ /dev/null @@ -1,19 +0,0 @@ -var Class = require('../../../utils/Class'); -var Event = require('../../../events/Event'); - -var BeforeUpdateEvent = new Class({ - - Extends: Event, - - initialize: - - function BeforeUpdateEvent (event) - { - Event.call(this, 'BEFORE_UPDATE_EVENT'); - - this.event = event; - } - -}); - -module.exports = BeforeUpdateEvent; diff --git a/src/physics/matter-js/events/CollisionActiveEvent.js b/src/physics/matter-js/events/CollisionActiveEvent.js deleted file mode 100644 index 4b10010a3..000000000 --- a/src/physics/matter-js/events/CollisionActiveEvent.js +++ /dev/null @@ -1,25 +0,0 @@ -var Class = require('../../../utils/Class'); -var Event = require('../../../events/Event'); - -var CollisionActiveEvent = new Class({ - - Extends: Event, - - initialize: - - function CollisionActiveEvent (pairs) - { - Event.call(this, 'COLLISION_ACTIVE_EVENT'); - - this.pairs = pairs; - - if (pairs.pairs.length > 0) - { - this.bodyA = pairs.pairs[0].bodyA; - this.bodyB = pairs.pairs[0].bodyB; - } - } - -}); - -module.exports = CollisionActiveEvent; diff --git a/src/physics/matter-js/events/CollisionEndEvent.js b/src/physics/matter-js/events/CollisionEndEvent.js deleted file mode 100644 index c1b7beadf..000000000 --- a/src/physics/matter-js/events/CollisionEndEvent.js +++ /dev/null @@ -1,25 +0,0 @@ -var Class = require('../../../utils/Class'); -var Event = require('../../../events/Event'); - -var CollisionEndEvent = new Class({ - - Extends: Event, - - initialize: - - function CollisionEndEvent (pairs) - { - Event.call(this, 'COLLISION_END_EVENT'); - - this.pairs = pairs; - - if (pairs.pairs.length > 0) - { - this.bodyA = pairs.pairs[0].bodyA; - this.bodyB = pairs.pairs[0].bodyB; - } - } - -}); - -module.exports = CollisionEndEvent; diff --git a/src/physics/matter-js/events/CollisionStartEvent.js b/src/physics/matter-js/events/CollisionStartEvent.js deleted file mode 100644 index 145761245..000000000 --- a/src/physics/matter-js/events/CollisionStartEvent.js +++ /dev/null @@ -1,25 +0,0 @@ -var Class = require('../../../utils/Class'); -var Event = require('../../../events/Event'); - -var CollisionStartEvent = new Class({ - - Extends: Event, - - initialize: - - function CollisionStartEvent (pairs) - { - Event.call(this, 'COLLISION_START_EVENT'); - - this.pairs = pairs; - - if (pairs.length > 0) - { - this.bodyA = pairs[0].bodyA; - this.bodyB = pairs[0].bodyB; - } - } - -}); - -module.exports = CollisionStartEvent; diff --git a/src/physics/matter-js/events/SleepEndEvent.js b/src/physics/matter-js/events/SleepEndEvent.js deleted file mode 100644 index 4afab283f..000000000 --- a/src/physics/matter-js/events/SleepEndEvent.js +++ /dev/null @@ -1,19 +0,0 @@ -var Class = require('../../../utils/Class'); -var Event = require('../../../events/Event'); - -var SleepEndEvent = new Class({ - - Extends: Event, - - initialize: - - function SleepEndEvent (event, body) - { - Event.call(this, 'SLEEP_END_EVENT'); - - this.body = body; - } - -}); - -module.exports = SleepEndEvent; diff --git a/src/physics/matter-js/events/SleepStartEvent.js b/src/physics/matter-js/events/SleepStartEvent.js deleted file mode 100644 index c437c3a08..000000000 --- a/src/physics/matter-js/events/SleepStartEvent.js +++ /dev/null @@ -1,20 +0,0 @@ -var Class = require('../../../utils/Class'); -var Event = require('../../../events/Event'); - -var SleepStartEvent = new Class({ - - Extends: Event, - - initialize: - - function SleepStartEvent (event, body) - { - Event.call(this, 'SLEEP_START_EVENT'); - - this.body = body; - - } - -}); - -module.exports = SleepStartEvent; diff --git a/src/physics/matter-js/events/index.js b/src/physics/matter-js/events/index.js deleted file mode 100644 index 28e77978c..000000000 --- a/src/physics/matter-js/events/index.js +++ /dev/null @@ -1,13 +0,0 @@ -// Phaser.Physics.Matter.Events - -module.exports = { - - AFTER_UPDATE: require('./AfterUpdateEvent'), - BEFORE_UPDATE: require('./BeforeUpdateEvent'), - COLLISION_ACTIVE: require('./CollisionActiveEvent'), - COLLISION_END: require('./CollisionEndEvent'), - COLLISION_START: require('./CollisionStartEvent'), - SLEEP_END: require('./SleepEndEvent'), - SLEEP_START: require('./SleepStartEvent') - -}; diff --git a/src/scene/plugins/InputManager.js b/src/scene/plugins/InputManager.js index ecbeff1a7..e8549678c 100644 --- a/src/scene/plugins/InputManager.js +++ b/src/scene/plugins/InputManager.js @@ -1,5 +1,4 @@ var Class = require('../../utils/Class'); -var InputEvent = require('../../input/local/events'); var SceneInputManager = require('../../input/local/SceneInputManager'); var InputManager = new Class({ @@ -11,11 +10,6 @@ var InputManager = new Class({ function InputManager (scene) { SceneInputManager.call(this, scene); - }, - - pointScreenToWorldHitTest: function (gameObjects, x, y, camera) - { - return this.manager.pointScreenToWorldHitTest(gameObjects, x, y, camera); } }); diff --git a/src/sound/SoundEvent.js b/src/sound/SoundEvent.js deleted file mode 100644 index 11c1ec348..000000000 --- a/src/sound/SoundEvent.js +++ /dev/null @@ -1,19 +0,0 @@ -var Class = require('../utils/Class'); -var Event = require('../events/Event'); - -var SoundEvent = new Class({ - - Extends: Event, - - initialize: - - function SoundEvent (sound, type) - { - Event.call(this, type); - - this.sound = sound; - } - -}); - -module.exports = SoundEvent; diff --git a/src/sound/SoundValueEvent.js b/src/sound/SoundValueEvent.js deleted file mode 100644 index c7e0eb33e..000000000 --- a/src/sound/SoundValueEvent.js +++ /dev/null @@ -1,19 +0,0 @@ -var Class = require('../utils/Class'); -var SoundEvent = require('./SoundEvent'); - -var SoundValueEvent = new Class({ - - Extends: SoundEvent, - - initialize: - - function SoundValueEvent (sound, type, value) - { - SoundEvent.call(this, sound, type); - - this.value = value; - } - -}); - -module.exports = SoundValueEvent; diff --git a/src/sound/index.js b/src/sound/index.js index bc4cab78c..1bd8f2d1a 100644 --- a/src/sound/index.js +++ b/src/sound/index.js @@ -11,8 +11,6 @@ module.exports = { WebAudioSoundManager: require('./webaudio/WebAudioSoundManager'), HTML5AudioSound: require('./html5/HTML5AudioSound'), - HTML5AudioSoundManager: require('./html5/HTML5AudioSoundManager'), + HTML5AudioSoundManager: require('./html5/HTML5AudioSoundManager') - SoundEvent: require('./SoundEvent'), - SoundValueEvent: require('./SoundValueEvent') };