mirror of
https://github.com/photonstorm/phaser
synced 2025-02-16 14:08:28 +00:00
Updated to using Event Emitter for all key managers and game objects. Events are now dispatched directly using arguments instead of Event objects, all managers updated to emit directly.
This commit is contained in:
parent
296efe0e07
commit
c625b8735b
48 changed files with 315 additions and 328 deletions
|
@ -42,5 +42,8 @@
|
|||
"uuid": "^3.1.0",
|
||||
"webpack": "^3.10.0",
|
||||
"webpack-shell-plugin": "^0.5.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"eventemitter3": "^3.0.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,8 +99,8 @@ var Animation = new Class({
|
|||
// Global pause, effects all Game Objects using this Animation instance
|
||||
this.paused = false;
|
||||
|
||||
this.manager.events.on('PAUSE_ALL_ANIMATION_EVENT', this.pause.bind(this));
|
||||
this.manager.events.on('RESUME_ALL_ANIMATION_EVENT', this.resume.bind(this));
|
||||
this.manager.on('pauseall', this.pause.bind(this));
|
||||
this.manager.on('resumeall', this.resume.bind(this));
|
||||
},
|
||||
|
||||
addFrame: require('./inc/AddFrame'),
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
var Class = require('../../utils/Class');
|
||||
var EventDispatcher = require('../../events/EventDispatcher');
|
||||
var EventEmitter = require('eventemitter3');
|
||||
var CustomMap = require('../../structs/Map');
|
||||
|
||||
// Animations are managed by the global AnimationManager. This is a singleton class that is
|
||||
|
@ -9,6 +9,8 @@ var CustomMap = require('../../structs/Map');
|
|||
|
||||
var AnimationManager = new Class({
|
||||
|
||||
Extends: EventEmitter,
|
||||
|
||||
initialize:
|
||||
|
||||
/**
|
||||
|
@ -23,6 +25,8 @@ var AnimationManager = new Class({
|
|||
*/
|
||||
function AnimationManager (game)
|
||||
{
|
||||
EventEmitter.call(this);
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
|
@ -39,14 +43,6 @@ var AnimationManager = new Class({
|
|||
*/
|
||||
this.textureManager = null;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @property {Phaser.Events.EventDispatcher} events
|
||||
* @protected
|
||||
*/
|
||||
this.events = new EventDispatcher();
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
var Event = require('../events/');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
|
@ -16,7 +14,7 @@ var AddAnimation = function (key, animation)
|
|||
{
|
||||
if (this.anims.has(key))
|
||||
{
|
||||
console.error('Animation with key', key, 'already exists');
|
||||
console.warn('Animation with key', key, 'already exists');
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -24,7 +22,7 @@ var AddAnimation = function (key, animation)
|
|||
|
||||
this.anims.set(key, animation);
|
||||
|
||||
this.events.dispatch(new Event.ADD_ANIMATION_EVENT(key, animation));
|
||||
this.emit('add', key, animation);
|
||||
|
||||
return this;
|
||||
};
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
var Event = require('../events/');
|
||||
var Animation = require('../../frame/Animation');
|
||||
|
||||
/**
|
||||
|
@ -26,7 +25,7 @@ var CreateFrameAnimation = function (config)
|
|||
|
||||
this.anims.set(key, anim);
|
||||
|
||||
this.events.dispatch(new Event.ADD_ANIMATION_EVENT(key, anim));
|
||||
this.emit('add', key, anim);
|
||||
|
||||
return anim;
|
||||
};
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
var Event = require('../events/');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
|
@ -15,7 +13,7 @@ var PauseAll = function ()
|
|||
{
|
||||
this.paused = true;
|
||||
|
||||
this.events.dispatch(new Event.PAUSE_ALL_ANIMATION_EVENT());
|
||||
this.emit('pauseall');
|
||||
}
|
||||
|
||||
return this;
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
var Event = require('../events/');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
|
@ -17,7 +15,7 @@ var RemoveAnimation = function (key)
|
|||
|
||||
if (anim)
|
||||
{
|
||||
this.events.dispatch(new Event.REMOVE_ANIMATION_EVENT(key, anim));
|
||||
this.emit('remove', key, anim);
|
||||
|
||||
this.anims.delete(key);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
var Event = require('../events/');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
|
@ -15,7 +13,7 @@ var ResumeAll = function ()
|
|||
{
|
||||
this.paused = false;
|
||||
|
||||
this.events.dispatch(new Event.RESUME_ALL_ANIMATION_EVENT());
|
||||
this.emit('resumeall');
|
||||
}
|
||||
|
||||
return this;
|
||||
|
|
|
@ -6,7 +6,7 @@ var NOOP = require('../utils/NOOP');
|
|||
|
||||
var AddToDOM = require('../dom/AddToDOM');
|
||||
var DOMContentLoaded = require('../dom/DOMContentLoaded');
|
||||
var EventDispatcher = require('../events/EventDispatcher');
|
||||
var EventEmitter = require('eventemitter3');
|
||||
var VisibilityHandler = require('./VisibilityHandler');
|
||||
|
||||
var AnimationManager = require('../animations/manager/AnimationManager');
|
||||
|
@ -82,7 +82,7 @@ var Game = new Class({
|
|||
*
|
||||
* @property {Phaser.Events.EventDispatcher} events
|
||||
*/
|
||||
this.events = new EventDispatcher();
|
||||
this.events = new EventEmitter();
|
||||
|
||||
/**
|
||||
* [description]
|
||||
|
@ -195,10 +195,10 @@ var Game = new Class({
|
|||
|
||||
VisibilityHandler(this.events);
|
||||
|
||||
this.events.on('HIDDEN', this.onHidden.bind(this));
|
||||
this.events.on('VISIBLE', this.onVisible.bind(this));
|
||||
this.events.on('ON_BLUR', this.onBlur.bind(this));
|
||||
this.events.on('ON_FOCUS', this.onFocus.bind(this));
|
||||
this.events.on('hidden', this.onHidden.bind(this));
|
||||
this.events.on('visible', this.onVisible.bind(this));
|
||||
this.events.on('blur', this.onBlur.bind(this));
|
||||
this.events.on('focus', this.onFocus.bind(this));
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
var Event = require('../events/Event');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @function Phaser.Boot.VisibilityHandler
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Events.EventDispatcher} eventDispatcher - The EventDispatcher that will dispatch the visibility events.
|
||||
* @param {Phaser.Events.EventDispatcher} eventEmitter - The EventDispatcher that will dispatch the visibility events.
|
||||
*/
|
||||
var VisibilityHandler = function (eventDispatcher)
|
||||
var VisibilityHandler = function (eventEmitter)
|
||||
{
|
||||
var hiddenVar;
|
||||
|
||||
|
@ -39,11 +37,11 @@ var VisibilityHandler = function (eventDispatcher)
|
|||
{
|
||||
if (document.hidden || event.type === 'pause')
|
||||
{
|
||||
eventDispatcher.dispatch(new Event('HIDDEN'));
|
||||
eventEmitter.emit('hidden');
|
||||
}
|
||||
else
|
||||
{
|
||||
eventDispatcher.dispatch(new Event('VISIBLE'));
|
||||
eventEmitter.emit('visible');
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -60,12 +58,12 @@ var VisibilityHandler = function (eventDispatcher)
|
|||
|
||||
window.onblur = function ()
|
||||
{
|
||||
eventDispatcher.dispatch(new Event('ON_BLUR'));
|
||||
eventEmitter.emit('blur');
|
||||
};
|
||||
|
||||
window.onfocus = function ()
|
||||
{
|
||||
eventDispatcher.dispatch(new Event('ON_FOCUS'));
|
||||
eventEmitter.emit('focus');
|
||||
};
|
||||
};
|
||||
|
||||
|
|
9
src/cache/BaseCache.js
vendored
9
src/cache/BaseCache.js
vendored
|
@ -1,7 +1,6 @@
|
|||
var Class = require('../utils/Class');
|
||||
var CustomMap = require('../structs/Map');
|
||||
var EventDispatcher = require('../events/EventDispatcher');
|
||||
var Events = require('./events');
|
||||
var EventEmitter = require('eventemitter3');
|
||||
|
||||
var BaseCache = new Class({
|
||||
|
||||
|
@ -29,7 +28,7 @@ var BaseCache = new Class({
|
|||
*
|
||||
* @property {Phaser.Events.EventDispatcher} events
|
||||
*/
|
||||
this.events = new EventDispatcher();
|
||||
this.events = new EventEmitter();
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -46,7 +45,7 @@ var BaseCache = new Class({
|
|||
{
|
||||
this.entries.set(key, data);
|
||||
|
||||
this.events.dispatch(new Events.CACHE_ADD_EVENT(this, key, data));
|
||||
this.events.emit('add', this, key, data);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -96,7 +95,7 @@ var BaseCache = new Class({
|
|||
{
|
||||
this.entries.delete(key);
|
||||
|
||||
this.events.dispatch(new Events.CACHE_REMOVE_EVENT(this, key, entry.data));
|
||||
this.events.emit('remove', this, key, entry.data);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
var Class = require('../utils/Class');
|
||||
var Event = require('../events/Event');
|
||||
var EventDispatcher = require('../events/EventDispatcher');
|
||||
var EventEmitter = require('eventemitter3');
|
||||
|
||||
/**
|
||||
* The Data Component features a means to store pieces of data specific to a Game Object,
|
||||
|
@ -14,7 +14,7 @@ var Data = new Class({
|
|||
{
|
||||
this.parent = parent;
|
||||
|
||||
this.events = (eventDispatcher) ? eventDispatcher : new EventDispatcher();
|
||||
this.events = (eventDispatcher) ? eventDispatcher : new EventEmitter();
|
||||
|
||||
this.list = {};
|
||||
|
||||
|
|
|
@ -178,6 +178,18 @@ var EventDispatcher = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
removeAllListeners: function (type)
|
||||
{
|
||||
var binding = this.getBinding(type);
|
||||
|
||||
if (binding)
|
||||
{
|
||||
binding.removeAll();
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
removeAllFilters: function ()
|
||||
{
|
||||
this.filters.length = 0;
|
||||
|
|
|
@ -7,9 +7,12 @@
|
|||
var Class = require('../utils/Class');
|
||||
var Components = require('./components');
|
||||
var DataProxy = require('./components/DataProxy');
|
||||
var EventEmitter = require('eventemitter3');
|
||||
|
||||
var GameObject = new Class({
|
||||
|
||||
Extends: EventEmitter,
|
||||
|
||||
initialize:
|
||||
|
||||
/**
|
||||
|
@ -26,6 +29,8 @@ var GameObject = new Class({
|
|||
*/
|
||||
function GameObject (scene, type)
|
||||
{
|
||||
EventEmitter.call(this);
|
||||
|
||||
/**
|
||||
* The Scene to which this Game Object belongs.
|
||||
* Game Objects can only belong to one Scene.
|
||||
|
@ -286,6 +291,7 @@ var GameObject = new Class({
|
|||
this.input = undefined;
|
||||
}
|
||||
|
||||
// TODO Keep a reference to the manager in Body, so body can remove itself, not via System
|
||||
if (this.body)
|
||||
{
|
||||
this.scene.sys.physicsManager.remove(this);
|
||||
|
@ -302,6 +308,8 @@ var GameObject = new Class({
|
|||
this.data = undefined;
|
||||
|
||||
this.scene = undefined;
|
||||
|
||||
this.removeAllListeners();
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -17,7 +17,7 @@ var Animation = new Class({
|
|||
|
||||
this.animationManager = parent.scene.sys.anims;
|
||||
|
||||
this.animationManager.events.once('REMOVE_ANIMATION_EVENT', this.remove.bind(this));
|
||||
this.animationManager.once('remove', this.remove, this);
|
||||
|
||||
this.isPlaying = false;
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ var Particle = new Class({
|
|||
return (this.lifeCurrent > 0);
|
||||
},
|
||||
|
||||
emit: function (x, y)
|
||||
fire: function (x, y)
|
||||
{
|
||||
var emitter = this.emitter;
|
||||
|
||||
|
|
|
@ -826,15 +826,15 @@ var ParticleEmitter = new Class({
|
|||
{
|
||||
this.frequency = -1;
|
||||
|
||||
return this.emit(count, x, y);
|
||||
return this.emitParticle(count, x, y);
|
||||
},
|
||||
|
||||
emitAt: function (x, y, count)
|
||||
emitParticleAt: function (x, y, count)
|
||||
{
|
||||
return this.emit(count, x, y);
|
||||
return this.emitParticle(count, x, y);
|
||||
},
|
||||
|
||||
emit: function (count, x, y)
|
||||
emitParticle: function (count, x, y)
|
||||
{
|
||||
if (this.atLimit())
|
||||
{
|
||||
|
@ -861,7 +861,7 @@ var ParticleEmitter = new Class({
|
|||
particle = new this.particleClass(this);
|
||||
}
|
||||
|
||||
particle.emit(x, y);
|
||||
particle.fire(x, y);
|
||||
|
||||
if (this.particleBringToTop)
|
||||
{
|
||||
|
@ -952,7 +952,7 @@ var ParticleEmitter = new Class({
|
|||
|
||||
if (this.frequency === 0)
|
||||
{
|
||||
this.emit();
|
||||
this.emitParticle();
|
||||
}
|
||||
else if (this.frequency > 0)
|
||||
{
|
||||
|
@ -960,7 +960,7 @@ var ParticleEmitter = new Class({
|
|||
|
||||
if (this._counter <= 0)
|
||||
{
|
||||
this.emit();
|
||||
this.emitParticle();
|
||||
|
||||
// counter = frequency - remained from previous delta
|
||||
this._counter = (this.frequency - Math.abs(this._counter));
|
||||
|
|
|
@ -132,7 +132,7 @@ var ParticleEmitterManager = new Class({
|
|||
return this.addGravityWell(new GravityWell(config));
|
||||
},
|
||||
|
||||
emit: function (count, x, y)
|
||||
emitParticle: function (count, x, y)
|
||||
{
|
||||
var emitters = this.emitters.list;
|
||||
|
||||
|
@ -142,16 +142,16 @@ var ParticleEmitterManager = new Class({
|
|||
|
||||
if (emitter.active)
|
||||
{
|
||||
emitter.emit(count, x, y);
|
||||
emitter.emitParticle(count, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
emitAt: function (x, y, count)
|
||||
emitParticleAt: function (x, y, count)
|
||||
{
|
||||
return this.emit(count, x, y);
|
||||
return this.emitParticle(count, x, y);
|
||||
},
|
||||
|
||||
pause: function ()
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Phaser.Input.Gamepad.Button
|
||||
|
||||
var Class = require('../../utils/Class');
|
||||
var GamepadEvent = require('./events/');
|
||||
|
||||
var Button = new Class({
|
||||
|
||||
|
@ -33,16 +32,13 @@ var Button = new Class({
|
|||
if (!this.pressed)
|
||||
{
|
||||
this.pressed = true;
|
||||
this.events.dispatch(new GamepadEvent.DOWN(this.pad, this, this.value, data));
|
||||
this.events.emit('down', this.pad, this, this.value, data);
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (this.pressed)
|
||||
{
|
||||
if (this.pressed)
|
||||
{
|
||||
this.pressed = false;
|
||||
this.events.dispatch(new GamepadEvent.UP(this.pad, this, this.value, data));
|
||||
}
|
||||
this.pressed = false;
|
||||
this.events.emit('up', this.pad, this, this.value, data);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
var Class = require('../../utils/Class');
|
||||
var Gamepad = require('./Gamepad');
|
||||
var GamepadEvent = require('./events/');
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API/Using_the_Gamepad_API
|
||||
|
@ -186,7 +185,7 @@ var GamepadManager = new Class({
|
|||
|
||||
pad = this.getPad(event.gamepad.index);
|
||||
|
||||
this.events.dispatch(new GamepadEvent.CONNECTED(pad, event));
|
||||
this.events.emit('connected', pad, event);
|
||||
|
||||
break;
|
||||
|
||||
|
@ -194,7 +193,7 @@ var GamepadManager = new Class({
|
|||
|
||||
pad = this.getPad(event.gamepad.index);
|
||||
|
||||
this.events.dispatch(new GamepadEvent.DISCONNECTED(pad, event));
|
||||
this.events.emit('disconnected', pad, event);
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Phaser.Input.GlobalInputManager
|
||||
|
||||
var Class = require('../../utils/Class');
|
||||
var EventDispatcher = require('../../events/EventDispatcher');
|
||||
var EventEmitter = require('eventemitter3');
|
||||
var Gamepad = require('../gamepad/GamepadManager');
|
||||
var HitTest = require('./inc/HitTest');
|
||||
var Keyboard = require('../keyboard/KeyboardManager');
|
||||
|
@ -24,7 +24,7 @@ var GlobalInputManager = new Class({
|
|||
|
||||
this.enabled = true;
|
||||
|
||||
this.events = new EventDispatcher();
|
||||
this.events = new EventEmitter();
|
||||
|
||||
// Standard FIFO queue
|
||||
this.queue = [];
|
||||
|
@ -145,7 +145,7 @@ var GlobalInputManager = new Class({
|
|||
|
||||
case 'pointerlockchange':
|
||||
|
||||
this.events.dispatch(new MouseEvent.POINTER_LOCK_CHANGE(event, this.mouse.locked));
|
||||
this.events.emit('pointerlockchange', event, this.mouse.locked);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
var Class = require('../../utils/Class');
|
||||
var Event = require('./events');
|
||||
var EventEmitter = require('eventemitter3');
|
||||
var Key = require('./keys/Key');
|
||||
var KeyCodes = require('./keys/KeyCodes');
|
||||
var KeyCombo = require('./combo/KeyCombo');
|
||||
|
@ -20,13 +20,15 @@ var ProcessKeyUp = require('./keys/ProcessKeyUp');
|
|||
|
||||
var KeyboardManager = new Class({
|
||||
|
||||
Extends: EventEmitter,
|
||||
|
||||
initialize:
|
||||
|
||||
function KeyboardManager (inputManager)
|
||||
{
|
||||
this.manager = inputManager;
|
||||
EventEmitter.call(this);
|
||||
|
||||
this.events = inputManager.events;
|
||||
this.manager = inputManager;
|
||||
|
||||
this.enabled = false;
|
||||
|
||||
|
@ -208,23 +210,18 @@ var KeyboardManager = new Class({
|
|||
var queue = this.queue.splice(0, len);
|
||||
|
||||
var keys = this.keys;
|
||||
var singleKey;
|
||||
|
||||
// Process the event queue, dispatching all of the events that have stored up
|
||||
for (var i = 0; i < len; i++)
|
||||
{
|
||||
var event = queue[i];
|
||||
|
||||
// Will emit a keyboard or keyup event
|
||||
this.emit(event.type, event);
|
||||
|
||||
if (event.type === 'keydown')
|
||||
{
|
||||
this.manager.events.dispatch(new Event.KEY_DOWN_EVENT(event));
|
||||
|
||||
singleKey = Event._DOWN[event.keyCode];
|
||||
|
||||
if (singleKey)
|
||||
{
|
||||
this.manager.events.dispatch(new singleKey(event));
|
||||
}
|
||||
this.emit('down_' + event.keyCode, event);
|
||||
|
||||
if (keys[event.keyCode])
|
||||
{
|
||||
|
@ -233,14 +230,7 @@ var KeyboardManager = new Class({
|
|||
}
|
||||
else
|
||||
{
|
||||
this.manager.events.dispatch(new Event.KEY_UP_EVENT(event));
|
||||
|
||||
singleKey = Event._UP[event.keyCode];
|
||||
|
||||
if (singleKey)
|
||||
{
|
||||
this.manager.events.dispatch(new singleKey(event));
|
||||
}
|
||||
this.emit('up_' + event.keyCode, event);
|
||||
|
||||
if (keys[event.keyCode])
|
||||
{
|
||||
|
@ -248,6 +238,24 @@ var KeyboardManager = new Class({
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
shutdown: function ()
|
||||
{
|
||||
this.removeAllListeners();
|
||||
},
|
||||
|
||||
destroy: function ()
|
||||
{
|
||||
this.stopListeners();
|
||||
|
||||
this.removeAllListeners();
|
||||
|
||||
this.keys = [];
|
||||
this.combos = [];
|
||||
this.captures = [];
|
||||
this.queue = [];
|
||||
this.handler = undefined;
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -95,7 +95,7 @@ var KeyCombo = new Class({
|
|||
|
||||
if (matched)
|
||||
{
|
||||
_this.manager.events.dispatch(new KeyComboMatchEvent(_this, event));
|
||||
_this.manager.emit('keycombomatch', _this, event);
|
||||
|
||||
if (_this.resetOnMatch)
|
||||
{
|
||||
|
@ -110,7 +110,7 @@ var KeyCombo = new Class({
|
|||
|
||||
this.onKeyDown = onKeyDownHandler;
|
||||
|
||||
this.manager.events.on('KEY_DOWN_EVENT', onKeyDownHandler);
|
||||
this.manager.on('keydown', onKeyDownHandler);
|
||||
},
|
||||
|
||||
progress: {
|
||||
|
@ -128,7 +128,7 @@ var KeyCombo = new Class({
|
|||
this.enabled = false;
|
||||
this.keyCodes = [];
|
||||
|
||||
this.manager.events.off('KEY_DOWN', this.onKeyDown);
|
||||
this.manager.off('keydown', this.onKeyDown);
|
||||
this.manager = undefined;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
var Class = require('../../utils/Class');
|
||||
var EventEmitter = require('eventemitter3');
|
||||
|
||||
// Drag Events
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API
|
||||
|
@ -7,10 +8,14 @@ var Class = require('../../utils/Class');
|
|||
|
||||
var SceneInputManager = new Class({
|
||||
|
||||
Extends: EventEmitter,
|
||||
|
||||
initialize:
|
||||
|
||||
function SceneInputManager (scene)
|
||||
{
|
||||
EventEmitter.call(this);
|
||||
|
||||
// The Scene that owns this plugin
|
||||
this.scene = scene;
|
||||
|
||||
|
@ -23,9 +28,6 @@ var SceneInputManager = new Class({
|
|||
// A reference to the this.scene.sys.cameras (set in boot)
|
||||
this.cameras;
|
||||
|
||||
// The Scene event dispatcher
|
||||
this.events = scene.sys.events;
|
||||
|
||||
// Proxy references available via the Scene
|
||||
this.keyboard = this.manager.keyboard;
|
||||
this.mouse = this.manager.mouse;
|
||||
|
@ -102,17 +104,6 @@ var SceneInputManager = new Class({
|
|||
|
||||
setDraggable: require('./inc/SetDraggable'),
|
||||
|
||||
setCallback: require('./inc/SetCallback'),
|
||||
setCallbacks: require('./inc/SetCallbacks'),
|
||||
setOnDownCallback: require('./inc/SetOnDownCallback'),
|
||||
setOnOutCallback: require('./inc/SetOnOutCallback'),
|
||||
setOnOverCallback: require('./inc/SetOnOverCallback'),
|
||||
setOnUpCallback: require('./inc/SetOnUpCallback'),
|
||||
setOnMoveCallback: require('./inc/SetOnMoveCallback'),
|
||||
setOnDragStartCallback: require('./inc/SetOnDragStartCallback'),
|
||||
setOnDragCallback: require('./inc/SetOnDragCallback'),
|
||||
setOnDragEndCallback: require('./inc/SetOnDragEndCallback'),
|
||||
|
||||
processOverOutEvents: require('./inc/ProcessOverOutEvents'),
|
||||
processDownEvents: require('./inc/ProcessDownEvents'),
|
||||
processDragEvents: require('./inc/ProcessDragEvents'),
|
||||
|
@ -166,6 +157,8 @@ var SceneInputManager = new Class({
|
|||
this._drag[i] = [];
|
||||
this._over[i] = [];
|
||||
}
|
||||
|
||||
this.removeAllListeners();
|
||||
},
|
||||
|
||||
// Game level nuke
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
var InputEvent = require('../events');
|
||||
|
||||
var ProcessDownEvents = function (pointer)
|
||||
{
|
||||
var currentlyOver = this._temp;
|
||||
|
||||
this.events.dispatch(new InputEvent.POINTER_DOWN(pointer, currentlyOver));
|
||||
// Contains ALL Game Objects currently over in the array
|
||||
this.emit('pointerdown', pointer, currentlyOver);
|
||||
|
||||
// Go through all objects the pointer was over and fire their events / callbacks
|
||||
for (var i = 0; i < currentlyOver.length; i++)
|
||||
|
@ -16,9 +15,9 @@ var ProcessDownEvents = function (pointer)
|
|||
continue;
|
||||
}
|
||||
|
||||
this.events.dispatch(new InputEvent.GAME_OBJECT_DOWN(pointer, gameObject));
|
||||
gameObject.emit('pointerdown', pointer, gameObject.input.localX, gameObject.input.localY, pointer.camera);
|
||||
|
||||
gameObject.input.onDown(gameObject, pointer, gameObject.input.localX, gameObject.input.localY);
|
||||
this.emit('gameobjectdown', pointer, gameObject);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
var DistanceBetween = require('../../../math/distance/DistanceBetween');
|
||||
var InputEvent = require('../events');
|
||||
|
||||
var ProcessDragEvents = function (pointer, time)
|
||||
{
|
||||
|
@ -118,12 +117,9 @@ var ProcessDragEvents = function (pointer, time)
|
|||
input.dragStartX = gameObject.x;
|
||||
input.dragStartY = gameObject.y;
|
||||
|
||||
this.events.dispatch(new InputEvent.DRAG_START(pointer, gameObject));
|
||||
gameObject.emit('dragstart', pointer, input.dragX, input.dragY);
|
||||
|
||||
if (gameObject.input)
|
||||
{
|
||||
input.onDragStart(gameObject, pointer, input.dragX, input.dragY);
|
||||
}
|
||||
this.emit('dragstart', pointer, gameObject);
|
||||
}
|
||||
|
||||
pointer.dragState = 4;
|
||||
|
@ -162,24 +158,29 @@ var ProcessDragEvents = function (pointer, time)
|
|||
if (index === 0)
|
||||
{
|
||||
// We're still over it, and it's still the top of the display list, phew ...
|
||||
this.events.dispatch(new InputEvent.DRAG_OVER(pointer, gameObject, input.target));
|
||||
gameObject.emit('dragover', pointer, input.target);
|
||||
|
||||
this.emit('dragover', pointer, gameObject, input.target);
|
||||
}
|
||||
else if (index > 0)
|
||||
{
|
||||
// Still over it but it's no longer top of the display list (targets must always be at the top)
|
||||
this.events.dispatch(new InputEvent.DRAG_LEAVE(pointer, gameObject, input.target));
|
||||
gameObject.emit('dragleave', pointer, input.target);
|
||||
|
||||
if (gameObject.input)
|
||||
{
|
||||
input.target = dropZones[0];
|
||||
}
|
||||
this.emit('dragleave', pointer, gameObject, input.target);
|
||||
|
||||
this.events.dispatch(new InputEvent.DRAG_ENTER(pointer, gameObject, input.target));
|
||||
input.target = dropZones[0];
|
||||
|
||||
gameObject.emit('dragenter', pointer, input.target);
|
||||
|
||||
this.emit('dragenter', pointer, gameObject, input.target);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Nope, we've moved on (or the target has!), leave the old target
|
||||
this.events.dispatch(new InputEvent.DRAG_LEAVE(pointer, gameObject, input.target));
|
||||
gameObject.emit('dragleave', pointer, input.target);
|
||||
|
||||
this.emit('dragleave', pointer, gameObject, input.target);
|
||||
|
||||
// Anything new to replace it?
|
||||
// Yup!
|
||||
|
@ -187,7 +188,9 @@ var ProcessDragEvents = function (pointer, time)
|
|||
{
|
||||
input.target = dropZones[0];
|
||||
|
||||
this.events.dispatch(new InputEvent.DRAG_ENTER(pointer, gameObject, input.target));
|
||||
gameObject.emit('dragenter', pointer, input.target);
|
||||
|
||||
this.emit('dragenter', pointer, gameObject, input.target);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -200,15 +203,16 @@ var ProcessDragEvents = function (pointer, time)
|
|||
{
|
||||
input.target = dropZones[0];
|
||||
|
||||
this.events.dispatch(new InputEvent.DRAG_ENTER(pointer, gameObject, input.target));
|
||||
gameObject.emit('dragenter', pointer, input.target);
|
||||
|
||||
this.emit('dragenter', pointer, gameObject, input.target);
|
||||
}
|
||||
|
||||
var dragEvent = new InputEvent.DRAG(pointer, gameObject);
|
||||
|
||||
this.events.dispatch(dragEvent);
|
||||
gameObject.emit('drag', pointer, dragEvent.dragX, dragEvent.dragY);
|
||||
|
||||
// Maybe it would be better to send the event to the callback? So you can get all the other stuff from it?
|
||||
input.onDrag(gameObject, pointer, dragEvent.dragX, dragEvent.dragY);
|
||||
this.emit('drag', dragEvent);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -232,7 +236,9 @@ var ProcessDragEvents = function (pointer, time)
|
|||
|
||||
if (input.target)
|
||||
{
|
||||
this.events.dispatch(new InputEvent.DROP(pointer, gameObject, input.target));
|
||||
gameObject.emit('drop', pointer, input.target);
|
||||
|
||||
this.emit('drop', pointer, gameObject, input.target);
|
||||
|
||||
input.target = null;
|
||||
|
||||
|
@ -241,12 +247,9 @@ var ProcessDragEvents = function (pointer, time)
|
|||
|
||||
// And finally the dragend event
|
||||
|
||||
this.events.dispatch(new InputEvent.DRAG_END(pointer, gameObject, dropped));
|
||||
gameObject.emit('dragend', pointer, input.dragX, input.dragY, dropped);
|
||||
|
||||
if (gameObject.input)
|
||||
{
|
||||
input.onDragEnd(gameObject, pointer, input.dragX, input.dragY);
|
||||
}
|
||||
this.emit('dragend', pointer, gameObject, dropped);
|
||||
}
|
||||
|
||||
pointer.dragState = 0;
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
var InputEvent = require('../events');
|
||||
|
||||
var ProcessMoveEvents = function (pointer)
|
||||
{
|
||||
var currentlyOver = this._temp;
|
||||
|
||||
this.events.dispatch(new InputEvent.POINTER_MOVE(pointer, currentlyOver));
|
||||
this.emit('pointermove', pointer, currentlyOver);
|
||||
|
||||
// Go through all objects the pointer was over and fire their events / callbacks
|
||||
for (var i = 0; i < currentlyOver.length; i++)
|
||||
|
@ -16,9 +14,9 @@ var ProcessMoveEvents = function (pointer)
|
|||
continue;
|
||||
}
|
||||
|
||||
this.events.dispatch(new InputEvent.GAME_OBJECT_MOVE(pointer, gameObject));
|
||||
gameObject.emit('pointermove', pointer, gameObject.input.localX, gameObject.input.localY);
|
||||
|
||||
gameObject.input.onMove(gameObject, pointer, gameObject.input.localX, gameObject.input.localY);
|
||||
this.emit('gameobjectmove', pointer, gameObject);
|
||||
|
||||
if (this.topOnly)
|
||||
{
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
var InputEvent = require('../events');
|
||||
|
||||
var ProcessOverOutEvents = function (pointer)
|
||||
{
|
||||
var currentlyOver = this._temp;
|
||||
|
@ -53,7 +51,7 @@ var ProcessOverOutEvents = function (pointer)
|
|||
{
|
||||
this.sortGameObjects(justOut);
|
||||
|
||||
this.events.dispatch(new InputEvent.POINTER_OUT(pointer, justOut));
|
||||
this.emit('pointerout', pointer, justOut);
|
||||
|
||||
// Call onOut for everything in the justOut array
|
||||
for (i = 0; i < total; i++)
|
||||
|
@ -65,9 +63,9 @@ var ProcessOverOutEvents = function (pointer)
|
|||
continue;
|
||||
}
|
||||
|
||||
this.events.dispatch(new InputEvent.GAME_OBJECT_OUT(pointer, gameObject));
|
||||
this.emit('gameobjectout', pointer, gameObject);
|
||||
|
||||
gameObject.input.onOut(gameObject, pointer);
|
||||
gameObject.emit('pointerout', pointer);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,7 +76,7 @@ var ProcessOverOutEvents = function (pointer)
|
|||
{
|
||||
this.sortGameObjects(justOver);
|
||||
|
||||
this.events.dispatch(new InputEvent.POINTER_OVER(pointer, justOver));
|
||||
this.emit('pointerover', pointer, justOver);
|
||||
|
||||
// Call onOver for everything in the justOver array
|
||||
for (i = 0; i < total; i++)
|
||||
|
@ -90,9 +88,9 @@ var ProcessOverOutEvents = function (pointer)
|
|||
continue;
|
||||
}
|
||||
|
||||
this.events.dispatch(new InputEvent.GAME_OBJECT_OVER(pointer, gameObject));
|
||||
this.emit('gameobjectover', pointer, gameObject);
|
||||
|
||||
gameObject.input.onOver(gameObject, pointer, gameObject.input.localX, gameObject.input.localY);
|
||||
gameObject.emit('pointerover', pointer, gameObject.input.localX, gameObject.input.localY);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
var InputEvent = require('../events');
|
||||
|
||||
var ProcessUpEvents = function (pointer)
|
||||
{
|
||||
var currentlyOver = this._temp;
|
||||
|
||||
this.events.dispatch(new InputEvent.POINTER_UP(pointer, currentlyOver));
|
||||
// Contains ALL Game Objects currently up in the array
|
||||
this.emit('pointerup', pointer, currentlyOver);
|
||||
|
||||
// Go through all objects the pointer was over and fire their events / callbacks
|
||||
for (var i = 0; i < currentlyOver.length; i++)
|
||||
|
@ -16,9 +15,9 @@ var ProcessUpEvents = function (pointer)
|
|||
continue;
|
||||
}
|
||||
|
||||
this.events.dispatch(new InputEvent.GAME_OBJECT_UP(pointer, gameObject));
|
||||
gameObject.emit('pointerup', pointer, gameObject.input.localX, gameObject.input.localY);
|
||||
|
||||
gameObject.input.onUp(gameObject, pointer, gameObject.input.localX, gameObject.input.localY);
|
||||
this.emit('gameobjectup', pointer, gameObject);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
|
||||
var Class = require('../utils/Class');
|
||||
var CONST = require('./const');
|
||||
var CustomSet = require('../structs/Set');
|
||||
var XHRSettings = require('./XHRSettings');
|
||||
var Event = require('./events/');
|
||||
// var EventDispatcher = require('../events/EventDispatcher');
|
||||
var Class = require('../utils/Class');
|
||||
var EventEmitter = require('eventemitter3');
|
||||
var ParseXMLBitmapFont = require('../gameobjects/bitmaptext/ParseXMLBitmapFont');
|
||||
var TilemapFormats = require("../gameobjects/tilemap/Formats");
|
||||
var TilemapFormats = require('../gameobjects/tilemap/Formats');
|
||||
var XHRSettings = require('./XHRSettings');
|
||||
|
||||
// Phaser.Loader.BaseLoader
|
||||
|
||||
|
@ -16,13 +14,15 @@ var TilemapFormats = require("../gameobjects/tilemap/Formats");
|
|||
|
||||
var BaseLoader = new Class({
|
||||
|
||||
Extends: EventEmitter,
|
||||
|
||||
initialize:
|
||||
|
||||
function BaseLoader (scene)
|
||||
{
|
||||
this.scene = scene;
|
||||
EventEmitter.call(this);
|
||||
|
||||
this.events = scene.sys.events;
|
||||
this.scene = scene;
|
||||
|
||||
// Move to a 'setURL' method?
|
||||
this.baseURL = '';
|
||||
|
@ -93,7 +93,7 @@ var BaseLoader = new Class({
|
|||
return;
|
||||
}
|
||||
|
||||
this.events.dispatch(new Event.LOADER_START_EVENT(this));
|
||||
this.emit('start', this);
|
||||
|
||||
if (this.list.size === 0)
|
||||
{
|
||||
|
@ -277,7 +277,7 @@ var BaseLoader = new Class({
|
|||
|
||||
this.state = CONST.LOADER_COMPLETE;
|
||||
|
||||
this.events.dispatch(new Event.LOADER_COMPLETE_EVENT(this));
|
||||
this.emit('complete', this, this.storage.size, this.failed.size);
|
||||
},
|
||||
|
||||
// The Loader has finished
|
||||
|
@ -500,8 +500,8 @@ var BaseLoader = new Class({
|
|||
this.queue.clear();
|
||||
this.storage.clear();
|
||||
|
||||
this.events.removeAll('LOADER_START_EVENT');
|
||||
this.events.removeAll('LOADER_COMPLETE_EVENT');
|
||||
this.removeAllListeners('start');
|
||||
this.removeAllListeners('complete');
|
||||
|
||||
this.tag = '';
|
||||
this.path = '';
|
||||
|
|
|
@ -5,14 +5,6 @@ var Extend = require('./utils/object/Extend');
|
|||
|
||||
// This object is exported globally
|
||||
|
||||
/*
|
||||
var Phaser = {
|
||||
|
||||
Game: require('./boot/Game')
|
||||
|
||||
};
|
||||
*/
|
||||
|
||||
var Phaser = {
|
||||
|
||||
Actions: require('./actions/'),
|
||||
|
@ -25,9 +17,6 @@ var Phaser = {
|
|||
|
||||
Game: require('./boot/Game'),
|
||||
|
||||
Event: require('./events/Event'),
|
||||
EventDispatcher: require('./events/EventDispatcher'),
|
||||
|
||||
Math: require('./math'),
|
||||
|
||||
Geom: require('./geom'),
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
var CircleContains = require('../../geom/circle/Contains');
|
||||
var Class = require('../../utils/Class');
|
||||
var CONST = require('./const');
|
||||
var PhysicsEvent = require('./events');
|
||||
var Rectangle = require('../../geom/rectangle/Rectangle');
|
||||
var RectangleContains = require('../../geom/rectangle/Contains');
|
||||
var Vector2 = require('../../math/Vector2');
|
||||
|
@ -267,7 +266,7 @@ var Body = new Class({
|
|||
|
||||
if (this.collideWorldBounds && this.checkWorldBounds() && this.onWorldBounds)
|
||||
{
|
||||
this.world.events.dispatch(new PhysicsEvent.WORLD_BOUNDS(this));
|
||||
this.world.emit('worldbounds', this, this.blocked.up, this.blocked.down, this.blocked.left, this.blocked.right);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,23 +4,26 @@ var Body = require('./Body');
|
|||
var Class = require('../../utils/Class');
|
||||
var Collider = require('./Collider');
|
||||
var CONST = require('./const');
|
||||
var EventEmitter = require('eventemitter3');
|
||||
var GetValue = require('../../utils/object/GetValue');
|
||||
var ProcessQueue = require('../../structs/ProcessQueue');
|
||||
var Rectangle = require('../../geom/rectangle/Rectangle');
|
||||
var RTree = require('../../structs/RTree');
|
||||
var Set = require('../../structs/Set');
|
||||
var ProcessQueue = require('../../structs/ProcessQueue');
|
||||
var StaticBody = require('./StaticBody');
|
||||
var Vector2 = require('../../math/Vector2');
|
||||
|
||||
var World = new Class({
|
||||
|
||||
Extends: EventEmitter,
|
||||
|
||||
initialize:
|
||||
|
||||
function World (scene, config)
|
||||
{
|
||||
this.scene = scene;
|
||||
EventEmitter.call(this);
|
||||
|
||||
this.events = scene.sys.events;
|
||||
this.scene = scene;
|
||||
|
||||
// Dynamic Bodies
|
||||
this.bodies = new Set();
|
||||
|
@ -241,6 +244,8 @@ var World = new Class({
|
|||
{
|
||||
this.isPaused = true;
|
||||
|
||||
this.emit('pause');
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
|
@ -248,6 +253,8 @@ var World = new Class({
|
|||
{
|
||||
this.isPaused = false;
|
||||
|
||||
this.emit('resume');
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
|
@ -413,12 +420,12 @@ var World = new Class({
|
|||
|
||||
shutdown: function ()
|
||||
{
|
||||
|
||||
this.removeAllListeners();
|
||||
},
|
||||
|
||||
destroy: function ()
|
||||
{
|
||||
|
||||
this.removeAllListeners();
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
var PhysicsEvent = require('../events');
|
||||
var SeparateX = require('./SeparateX');
|
||||
var SeparateY = require('./SeparateY');
|
||||
|
||||
|
@ -84,11 +83,11 @@ var Separate = function (body1, body2, processCallback, callbackContext, overlap
|
|||
{
|
||||
if (overlapOnly && (body1.onOverlap || body2.onOverlap))
|
||||
{
|
||||
this.events.dispatch(new PhysicsEvent.OVERLAP(body1.gameObject, body2.gameObject));
|
||||
this.emit('overlap', body1.gameObject, body2.gameObject, body1, body2);
|
||||
}
|
||||
else if (body1.onCollide || body2.onCollide)
|
||||
{
|
||||
this.events.dispatch(new PhysicsEvent.COLLIDE(body1.gameObject, body2.gameObject));
|
||||
this.emit('overlap', body1.gameObject, body2.gameObject, body1, body2);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
var DistanceBetween = require('../../../math/distance/DistanceBetween');
|
||||
var GetOverlapX = require('./GetOverlapX');
|
||||
var GetOverlapY = require('./GetOverlapY');
|
||||
var PhysicsEvent = require('../events');
|
||||
|
||||
var SeparateCircle = function (body1, body2, overlapOnly, bias)
|
||||
{
|
||||
|
@ -66,7 +65,7 @@ var SeparateCircle = function (body1, body2, overlapOnly, bias)
|
|||
{
|
||||
if (overlap !== 0 && (body1.onOverlap || body2.onOverlap))
|
||||
{
|
||||
this.events.dispatch(new PhysicsEvent.OVERLAP(body1.gameObject, body2.gameObject));
|
||||
this.emit('overlap', body1.gameObject, body2.gameObject, body1, body2);
|
||||
}
|
||||
|
||||
// return true if there was some overlap, otherwise false
|
||||
|
@ -176,7 +175,7 @@ var SeparateCircle = function (body1, body2, overlapOnly, bias)
|
|||
|
||||
if (body1.onCollide || body2.onCollide)
|
||||
{
|
||||
this.events.dispatch(new PhysicsEvent.COLLIDE(body1.gameObject, body2.gameObject));
|
||||
this.emit('collide', body1.gameObject, body2.gameObject, body1, body2);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
var SeperateX = require('./SeperateX');
|
||||
var SeperateY = require('./SeperateY');
|
||||
var COLLIDES = require('./COLLIDES');
|
||||
var Events = require('./events');
|
||||
|
||||
// Impact Physics Solver
|
||||
|
||||
|
@ -32,7 +31,7 @@ var Solver = function (world, bodyA, bodyB)
|
|||
bodyA.collideWith(bodyB, 'y');
|
||||
bodyB.collideWith(bodyA, 'y');
|
||||
|
||||
world.events.dispatch(new Events.COLLIDE(bodyA, bodyB, 'y'));
|
||||
world.emit('collide', bodyA, bodyB, 'y');
|
||||
}
|
||||
else if (bodyA.last.y + bodyA.size.y > bodyB.last.y && bodyA.last.y < bodyB.last.y + bodyB.size.y)
|
||||
{
|
||||
|
@ -48,7 +47,7 @@ var Solver = function (world, bodyA, bodyB)
|
|||
bodyA.collideWith(bodyB, 'x');
|
||||
bodyB.collideWith(bodyA, 'x');
|
||||
|
||||
world.events.dispatch(new Events.COLLIDE(bodyA, bodyB, 'x'));
|
||||
world.emit('collide', bodyA, bodyB, 'x');
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ var Body = require('./Body');
|
|||
var Class = require('../../utils/Class');
|
||||
var COLLIDES = require('./COLLIDES');
|
||||
var CollisionMap = require('./CollisionMap');
|
||||
var EventEmitter = require('eventemitter3');
|
||||
var GetFastValue = require('../../utils/object/GetFastValue');
|
||||
var Set = require('../../structs/Set');
|
||||
var Solver = require('./Solver');
|
||||
|
@ -11,13 +12,15 @@ var TYPE = require('./TYPE');
|
|||
|
||||
var World = new Class({
|
||||
|
||||
Extends: EventEmitter,
|
||||
|
||||
initialize:
|
||||
|
||||
function World (scene, config)
|
||||
{
|
||||
this.scene = scene;
|
||||
EventEmitter.call(this);
|
||||
|
||||
this.events = scene.sys.events;
|
||||
this.scene = scene;
|
||||
|
||||
this.bodies = new Set();
|
||||
|
||||
|
@ -486,14 +489,14 @@ var World = new Class({
|
|||
|
||||
shutdown: function ()
|
||||
{
|
||||
|
||||
this.removeAllListeners();
|
||||
},
|
||||
|
||||
destroy: function ()
|
||||
{
|
||||
this.scene = null;
|
||||
this.removeAllListeners();
|
||||
|
||||
this.events = null;
|
||||
this.scene = null;
|
||||
|
||||
this.bodies.clear();
|
||||
|
||||
|
|
|
@ -61,9 +61,9 @@ var PointerConstraint = new Class({
|
|||
|
||||
this.world.events.on('BEFORE_UPDATE_EVENT', this.update, 0, this);
|
||||
|
||||
scene.sys.events.on('POINTER_DOWN_EVENT', this.onDown, 0, this);
|
||||
scene.sys.events.on('pointerdown', this.onDown, 0, this);
|
||||
|
||||
scene.sys.events.on('POINTER_UP_EVENT', this.onUp, 0, this);
|
||||
scene.sys.events.on('pointerup', this.onUp, 0, this);
|
||||
},
|
||||
|
||||
onDown: function (event)
|
||||
|
@ -169,9 +169,9 @@ var PointerConstraint = new Class({
|
|||
|
||||
this.world.events.off('BEFORE_UPDATE_EVENT', this.update);
|
||||
|
||||
this.scene.sys.events.off('POINTER_DOWN_EVENT', this.onDown, 0, this);
|
||||
this.scene.sys.events.off('pointerdown', this.onDown, this);
|
||||
|
||||
this.scene.sys.events.off('POINTER_UP_EVENT', this.onUp, 0, this);
|
||||
this.scene.sys.events.off('pointerup', this.onUp, this);
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -4,7 +4,7 @@ var Bodies = require('./lib/factory/Bodies');
|
|||
var Class = require('../../utils/Class');
|
||||
var Composite = require('./lib/body/Composite');
|
||||
var Engine = require('./lib/core/Engine');
|
||||
var EventDispatcher = require('../../events/EventDispatcher');
|
||||
var EventEmitter = require('eventemitter3');
|
||||
var GetFastValue = require('../../utils/object/GetFastValue');
|
||||
var GetValue = require('../../utils/object/GetValue');
|
||||
var MatterBody = require('./lib/body/Body');
|
||||
|
@ -24,7 +24,7 @@ var World = new Class({
|
|||
|
||||
this.localWorld = this.engine.world;
|
||||
|
||||
this.events = new EventDispatcher();
|
||||
this.events = new EventEmitter();
|
||||
|
||||
var gravity = GetValue(config, 'gravity', null);
|
||||
|
||||
|
|
|
@ -5,61 +5,50 @@ var Plugin = new Class({
|
|||
|
||||
initialize:
|
||||
|
||||
function Plugin (scene)
|
||||
function Plugin (scene, systemName, sceneName)
|
||||
{
|
||||
if (sceneName === undefined) { sceneName = systemName; }
|
||||
|
||||
this.scene = scene;
|
||||
|
||||
this.mapping = '';
|
||||
|
||||
this.active = true;
|
||||
|
||||
this.priority = 0;
|
||||
this.system = {
|
||||
systemName: systemName,
|
||||
sceneName: sceneName,
|
||||
active: true,
|
||||
visible: true,
|
||||
priority: {
|
||||
begin: 0,
|
||||
update: 0,
|
||||
postUpdate: 0,
|
||||
render: 0,
|
||||
postRender: 0
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
pause: function ()
|
||||
setPriority: function (type, value)
|
||||
{
|
||||
|
||||
this.system.priority[type] = value;
|
||||
},
|
||||
|
||||
resume: function ()
|
||||
setActive: function (value)
|
||||
{
|
||||
|
||||
this.system.active = value;
|
||||
},
|
||||
|
||||
boot: function ()
|
||||
setVisible: function (value)
|
||||
{
|
||||
|
||||
this.system.visible = value;
|
||||
},
|
||||
|
||||
begin: function (time, delta)
|
||||
{
|
||||
|
||||
},
|
||||
|
||||
update: function (time, delta)
|
||||
{
|
||||
|
||||
},
|
||||
|
||||
postUpdate: function (time, delta)
|
||||
{
|
||||
|
||||
},
|
||||
|
||||
postRender: function (renderer)
|
||||
{
|
||||
|
||||
},
|
||||
|
||||
shutdown: function ()
|
||||
{
|
||||
|
||||
},
|
||||
|
||||
destroy: function ()
|
||||
{
|
||||
|
||||
}
|
||||
boot: NOOP,
|
||||
begin: NOOP,
|
||||
update: NOOP,
|
||||
postUpdate: NOOP,
|
||||
render: NOOP,
|
||||
postRender: NOOP,
|
||||
shutdown: NOOP,
|
||||
destroy: NOOP
|
||||
|
||||
});
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ var BootScene = function (scene)
|
|||
{
|
||||
// Start the loader going as we have something in the queue
|
||||
|
||||
loader.events.once('LOADER_COMPLETE_EVENT', this.loadComplete.bind(this));
|
||||
loader.once('complete', this.loadComplete, this);
|
||||
|
||||
loader.start();
|
||||
}
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
*
|
||||
* @param {object} event - [description]
|
||||
*/
|
||||
var LoadComplete = function (event)
|
||||
var LoadComplete = function (loader)
|
||||
{
|
||||
var scene = event.loader.scene;
|
||||
var scene = loader.scene;
|
||||
|
||||
this.create(scene);
|
||||
};
|
||||
|
|
|
@ -49,7 +49,7 @@ var Start = function (key, data)
|
|||
|
||||
if (loader.loadArray(scene.sys.settings.files))
|
||||
{
|
||||
loader.events.once('LOADER_COMPLETE_EVENT', this.payloadComplete.bind(this));
|
||||
loader.once('complete', this.payloadComplete, this);
|
||||
|
||||
loader.start();
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ var Clock = require('../../time/Clock');
|
|||
var Data = require('../../data/Data');
|
||||
var DataStore = require('../../data/DataStore');
|
||||
var DisplayList = require('../plugins/DisplayList');
|
||||
var EventDispatcher = require('../../events/EventDispatcher');
|
||||
var EventEmitter = require('eventemitter3');
|
||||
var GameObjectCreator = require('../plugins/GameObjectCreator');
|
||||
var GameObjectFactory = require('../plugins/GameObjectFactory');
|
||||
var InputManager = require('../plugins/InputManager');
|
||||
|
@ -12,11 +12,10 @@ var Loader = require('../plugins/Loader');
|
|||
var PhysicsManager = require('../plugins/PhysicsManager');
|
||||
var SceneManager = require('../plugins/SceneManager');
|
||||
var Settings = require('./Settings');
|
||||
var StableSort = require('../../utils/array/StableSort');
|
||||
var TweenManager = require('../../tweens/manager/TweenManager');
|
||||
var UpdateList = require('../plugins/UpdateList');
|
||||
|
||||
var PluginManager = require('../../plugins/PluginManager');
|
||||
// var PluginManager = require('../../plugins/PluginManager');
|
||||
|
||||
var Systems = new Class({
|
||||
|
||||
|
@ -26,16 +25,18 @@ var Systems = new Class({
|
|||
{
|
||||
this.scene = scene;
|
||||
|
||||
this.game;
|
||||
|
||||
this.config = config;
|
||||
|
||||
this.settings = Settings.create(config);
|
||||
|
||||
// Set by the GlobalSceneManager
|
||||
// Set by the GlobalSceneManager - a reference to the game canvas / context
|
||||
|
||||
this.canvas;
|
||||
this.context;
|
||||
|
||||
// CORE (GLOBAL) SYSTEMS / PROPERTIES
|
||||
|
||||
this.game;
|
||||
// Global Systems - these are global managers (belonging to Game)
|
||||
|
||||
this.anims;
|
||||
this.cache;
|
||||
|
@ -43,23 +44,27 @@ var Systems = new Class({
|
|||
this.sound;
|
||||
this.textures;
|
||||
|
||||
// Reference to Scene specific managers (Factory, Tweens, Loader, Physics, etc)
|
||||
this.add;
|
||||
// These are core Scene plugins, needed by lots of the global systems (and each other)
|
||||
|
||||
this.cameras;
|
||||
this.data;
|
||||
this.dataStore;
|
||||
this.displayList;
|
||||
this.events;
|
||||
this.sceneManager;
|
||||
this.time;
|
||||
this.updateList;
|
||||
|
||||
// Optional Scene plugins - not referenced by core systems, can be overridden with user code
|
||||
|
||||
// this.plugins;
|
||||
|
||||
this.add;
|
||||
this.data;
|
||||
this.dataStore;
|
||||
this.inputManager;
|
||||
this.load;
|
||||
this.make;
|
||||
this.physicsManager;
|
||||
this.sceneManager;
|
||||
this.time;
|
||||
this.tweens;
|
||||
this.updateList;
|
||||
|
||||
this.plugins;
|
||||
},
|
||||
|
||||
init: function (game)
|
||||
|
@ -68,7 +73,7 @@ var Systems = new Class({
|
|||
|
||||
this.game = game;
|
||||
|
||||
// Game (Global) level managers
|
||||
// Global Systems - these are global managers (belonging to Game)
|
||||
|
||||
this.anims = game.anims;
|
||||
this.cache = game.cache;
|
||||
|
@ -76,24 +81,27 @@ var Systems = new Class({
|
|||
this.sound = game.sound;
|
||||
this.textures = game.textures;
|
||||
|
||||
this.plugins = new PluginManager(scene);
|
||||
// These are core Scene plugins, needed by lots of the global systems (and each other)
|
||||
|
||||
// Scene specific managers (Factory, Tweens, Loader, Physics, etc)
|
||||
this.cameras = new CameraManager(scene);
|
||||
this.displayList = new DisplayList(scene);
|
||||
this.events = new EventEmitter();
|
||||
this.sceneManager = new SceneManager(scene);
|
||||
this.time = new Clock(scene);
|
||||
this.updateList = new UpdateList(scene);
|
||||
|
||||
// Optional Scene plugins - not referenced by core systems, can be overridden with user code
|
||||
|
||||
this.add = new GameObjectFactory(scene);
|
||||
this.cameras = new CameraManager(scene);
|
||||
this.data = new Data(scene);
|
||||
this.dataStore = new DataStore(scene);
|
||||
this.displayList = new DisplayList(scene);
|
||||
this.events = new EventDispatcher();
|
||||
this.inputManager = new InputManager(scene);
|
||||
this.load = new Loader(scene);
|
||||
this.make = new GameObjectCreator(scene);
|
||||
this.physicsManager = new PhysicsManager(scene);
|
||||
this.sceneManager = new SceneManager(scene);
|
||||
this.time = new Clock(scene);
|
||||
this.tweens = new TweenManager(scene);
|
||||
this.updateList = new UpdateList(scene);
|
||||
|
||||
// this.plugins = new PluginManager(scene);
|
||||
|
||||
// Sometimes the managers need access to a system created after them
|
||||
this.add.boot(this);
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
var Class = require('../utils/Class');
|
||||
var Extend = require('../utils/object/Extend');
|
||||
var EventDispatcher = require('../events/EventDispatcher');
|
||||
var EventEmitter = require('eventemitter3');
|
||||
var NOOP = require('../utils/NOOP');
|
||||
|
||||
/*!
|
||||
* @author Pavle Goloskokovic <pgoloskokovic@gmail.com> (http://prunegames.com)
|
||||
*/
|
||||
var BaseSound = new Class({
|
||||
|
||||
Extends: EventEmitter,
|
||||
|
||||
/**
|
||||
* @class Phaser.Sound.BaseSound
|
||||
* @constructor
|
||||
|
@ -14,6 +18,9 @@ var BaseSound = new Class({
|
|||
* @param {ISoundConfig} [config] - An optional config object containing default sound settings.
|
||||
*/
|
||||
initialize: function BaseSound(manager, key, config) {
|
||||
|
||||
EventEmitter.call(this);
|
||||
|
||||
/**
|
||||
* Local reference to the sound manager.
|
||||
*
|
||||
|
@ -28,13 +35,6 @@ var BaseSound = new Class({
|
|||
* @property {string} key
|
||||
*/
|
||||
this.key = key;
|
||||
/**
|
||||
* Event dispatcher used to handle all sound instance related events.
|
||||
*
|
||||
* @readonly
|
||||
* @property {Phaser.Events.EventDispatcher}
|
||||
*/
|
||||
this.events = new EventDispatcher();
|
||||
/**
|
||||
* Flag indicating if sound is currently playing.
|
||||
*
|
||||
|
@ -380,8 +380,7 @@ var BaseSound = new Class({
|
|||
this.pendingRemove = true;
|
||||
this.manager = null;
|
||||
this.key = '';
|
||||
this.events.destroy();
|
||||
this.events = null;
|
||||
this.removeAllListeners();
|
||||
this.isPlaying = false;
|
||||
this.isPaused = false;
|
||||
this.config = null;
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
var Class = require('../utils/Class');
|
||||
var NOOP = require('../utils/NOOP');
|
||||
var EventDispatcher = require('../events/EventDispatcher');
|
||||
var SoundEvent = require('./SoundEvent');
|
||||
var SoundValueEvent = require('./SoundValueEvent');
|
||||
var EventEmitter = require('eventemitter3');
|
||||
|
||||
/*!
|
||||
* @author Pavle Goloskokovic <pgoloskokovic@gmail.com> (http://prunegames.com)
|
||||
*/
|
||||
var BaseSoundManager = new Class({
|
||||
|
||||
Extends: EventEmitter,
|
||||
|
||||
/**
|
||||
* The sound manager is responsible for playing back audio via Web Audio API or HTML Audio tag as fallback.
|
||||
* The audio file type and the encoding of those files are extremely important.
|
||||
|
@ -18,6 +20,9 @@ var BaseSoundManager = new Class({
|
|||
* @param {Phaser.Game} game - Reference to the current game instance.
|
||||
*/
|
||||
initialize: function BaseSoundManager(game) {
|
||||
|
||||
EventEmitter.call(this);
|
||||
|
||||
/**
|
||||
* Local reference to game.
|
||||
*
|
||||
|
@ -25,13 +30,6 @@ var BaseSoundManager = new Class({
|
|||
* @property {Phaser.Game} game
|
||||
*/
|
||||
this.game = game;
|
||||
/**
|
||||
* Event dispatcher used to handle all sound manager related events.
|
||||
*
|
||||
* @readonly
|
||||
* @property {Phaser.Events.EventDispatcher} events
|
||||
*/
|
||||
this.events = new EventDispatcher();
|
||||
/**
|
||||
* An array containing all added sounds.
|
||||
*
|
||||
|
@ -79,16 +77,16 @@ var BaseSoundManager = new Class({
|
|||
* @default true
|
||||
*/
|
||||
this.pauseOnBlur = true;
|
||||
game.events.on('ON_BLUR', function () {
|
||||
game.events.on('blur', function () {
|
||||
if (this.pauseOnBlur) {
|
||||
this.onBlur();
|
||||
}
|
||||
}.bind(this));
|
||||
game.events.on('ON_FOCUS', function () {
|
||||
}, this);
|
||||
game.events.on('focus', function () {
|
||||
if (this.pauseOnBlur) {
|
||||
this.onFocus();
|
||||
}
|
||||
}.bind(this));
|
||||
}, this);
|
||||
/**
|
||||
* Property that actually holds the value of global playback rate.
|
||||
*
|
||||
|
@ -156,7 +154,7 @@ var BaseSoundManager = new Class({
|
|||
*/
|
||||
play: function (key, extra) {
|
||||
var sound = this.add(key);
|
||||
sound.events.once('SOUND_ENDED', sound.destroy.bind(sound));
|
||||
sound.once('ended', sound.destroy, sound);
|
||||
if (extra) {
|
||||
if (extra.name) {
|
||||
sound.addMarker(extra);
|
||||
|
@ -181,7 +179,7 @@ var BaseSoundManager = new Class({
|
|||
*/
|
||||
playAudioSprite: function (key, spriteName, config) {
|
||||
var sound = this.addAudioSprite(key);
|
||||
sound.events.once('SOUND_ENDED', sound.destroy.bind(sound));
|
||||
sound.once('ended', sound.destroy, sound);
|
||||
sound.play(spriteName, config);
|
||||
},
|
||||
/**
|
||||
|
@ -230,7 +228,7 @@ var BaseSoundManager = new Class({
|
|||
this.forEachActiveSound(function (sound) {
|
||||
sound.pause();
|
||||
});
|
||||
this.events.dispatch(new SoundEvent(this, 'SOUND_PAUSE'));
|
||||
this.emit('pauseall');
|
||||
},
|
||||
/**
|
||||
* Resumes all the sounds in the game.
|
||||
|
@ -241,7 +239,7 @@ var BaseSoundManager = new Class({
|
|||
this.forEachActiveSound(function (sound) {
|
||||
sound.resume();
|
||||
});
|
||||
this.events.dispatch(new SoundEvent(this, 'SOUND_RESUME'));
|
||||
this.emit('resumeall');
|
||||
},
|
||||
/**
|
||||
* Stops all the sounds in the game.
|
||||
|
@ -252,7 +250,7 @@ var BaseSoundManager = new Class({
|
|||
this.forEachActiveSound(function (sound) {
|
||||
sound.stop();
|
||||
});
|
||||
this.events.dispatch(new SoundEvent(this, 'SOUND_STOP'));
|
||||
this.emit('stopall');
|
||||
},
|
||||
/**
|
||||
* Method used internally for pausing sound manager if
|
||||
|
@ -298,8 +296,7 @@ var BaseSoundManager = new Class({
|
|||
*/
|
||||
destroy: function () {
|
||||
this.game = null;
|
||||
this.events.destroy();
|
||||
this.events = null;
|
||||
this.removeAllListeners();
|
||||
this.forEachActiveSound(function (sound) {
|
||||
sound.destroy();
|
||||
});
|
||||
|
@ -338,7 +335,7 @@ Object.defineProperty(BaseSoundManager.prototype, 'rate', {
|
|||
this.forEachActiveSound(function (sound) {
|
||||
sound.setRate();
|
||||
});
|
||||
this.events.dispatch(new SoundValueEvent(this, 'SOUND_RATE', value));
|
||||
this.emit('rate', value);
|
||||
}
|
||||
});
|
||||
/**
|
||||
|
@ -356,7 +353,7 @@ Object.defineProperty(BaseSoundManager.prototype, 'detune', {
|
|||
this.forEachActiveSound(function (sound) {
|
||||
sound.setRate();
|
||||
});
|
||||
this.events.dispatch(new SoundValueEvent(this, 'SOUND_DETUNE', value));
|
||||
this.emit('detune', value);
|
||||
}
|
||||
});
|
||||
module.exports = BaseSoundManager;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
var Class = require('../../utils/Class');
|
||||
var BaseSound = require('../BaseSound');
|
||||
var SoundEvent = require('../SoundEvent');
|
||||
var SoundValueEvent = require('../SoundValueEvent');
|
||||
|
||||
/*!
|
||||
* @author Pavle Goloskokovic <pgoloskokovic@gmail.com> (http://prunegames.com)
|
||||
*/
|
||||
|
@ -134,7 +133,7 @@ var WebAudioSound = new Class({
|
|||
// \/\/\/ isPlaying = true, isPaused = false \/\/\/
|
||||
this.stopAndRemoveBufferSource();
|
||||
this.createAndStartBufferSource();
|
||||
this.events.dispatch(new SoundEvent(this, 'SOUND_PLAY'));
|
||||
this.emit('play', this);
|
||||
return this;
|
||||
},
|
||||
/**
|
||||
|
@ -153,7 +152,7 @@ var WebAudioSound = new Class({
|
|||
// \/\/\/ isPlaying = false, isPaused = true \/\/\/
|
||||
this.currentConfig.seek = this.getCurrentTime(); // Equivalent to setting paused time
|
||||
this.stopAndRemoveBufferSource();
|
||||
this.events.dispatch(new SoundEvent(this, 'SOUND_PAUSE'));
|
||||
this.emit('pause', this);
|
||||
return true;
|
||||
},
|
||||
/**
|
||||
|
@ -171,7 +170,7 @@ var WebAudioSound = new Class({
|
|||
}
|
||||
// \/\/\/ isPlaying = true, isPaused = false \/\/\/
|
||||
this.createAndStartBufferSource();
|
||||
this.events.dispatch(new SoundEvent(this, 'SOUND_RESUME'));
|
||||
this.emit('resume', this);
|
||||
return true;
|
||||
},
|
||||
/**
|
||||
|
@ -186,7 +185,7 @@ var WebAudioSound = new Class({
|
|||
}
|
||||
// \/\/\/ isPlaying = false, isPaused = false \/\/\/
|
||||
this.stopAndRemoveBufferSource();
|
||||
this.events.dispatch(new SoundEvent(this, 'SOUND_STOP'));
|
||||
this.emit('stop', this);
|
||||
return true;
|
||||
},
|
||||
/**
|
||||
|
@ -306,7 +305,7 @@ var WebAudioSound = new Class({
|
|||
this.hasEnded = false;
|
||||
BaseSound.prototype.stop.call(this);
|
||||
this.stopAndRemoveBufferSource();
|
||||
this.events.dispatch(new SoundEvent(this, 'SOUND_ENDED'));
|
||||
this.emit('ended', this);
|
||||
}
|
||||
else if (this.hasLooped) {
|
||||
this.hasLooped = false;
|
||||
|
@ -319,7 +318,7 @@ var WebAudioSound = new Class({
|
|||
rate: this.totalRate
|
||||
});
|
||||
this.createAndStartLoopBufferSource();
|
||||
this.events.dispatch(new SoundEvent(this, 'SOUND_LOOP'));
|
||||
this.emit('loop', this);
|
||||
}
|
||||
},
|
||||
/**
|
||||
|
@ -413,7 +412,7 @@ Object.defineProperty(WebAudioSound.prototype, 'mute', {
|
|||
set: function (value) {
|
||||
this.currentConfig.mute = value;
|
||||
this.muteNode.gain.setValueAtTime(value ? 0 : 1, 0);
|
||||
this.events.dispatch(new SoundValueEvent(this, 'SOUND_MUTE', value));
|
||||
this.emit('mute', this, value);
|
||||
}
|
||||
});
|
||||
/**
|
||||
|
@ -429,7 +428,7 @@ Object.defineProperty(WebAudioSound.prototype, 'volume', {
|
|||
set: function (value) {
|
||||
this.currentConfig.volume = value;
|
||||
this.volumeNode.gain.setValueAtTime(value, 0);
|
||||
this.events.dispatch(new SoundValueEvent(this, 'SOUND_VOLUME', value));
|
||||
this.emit('volume', this, value);
|
||||
}
|
||||
});
|
||||
/**
|
||||
|
@ -445,7 +444,7 @@ Object.defineProperty(WebAudioSound.prototype, 'rate', {
|
|||
set: function (value) {
|
||||
this.currentConfig.rate = value;
|
||||
this.setRate();
|
||||
this.events.dispatch(new SoundValueEvent(this, 'SOUND_RATE', value));
|
||||
this.emit('rate', this, value);
|
||||
}
|
||||
});
|
||||
/**
|
||||
|
@ -461,7 +460,7 @@ Object.defineProperty(WebAudioSound.prototype, 'detune', {
|
|||
set: function (value) {
|
||||
this.currentConfig.detune = value;
|
||||
this.setRate();
|
||||
this.events.dispatch(new SoundValueEvent(this, 'SOUND_DETUNE', value));
|
||||
this.emit('detune', this, value);
|
||||
}
|
||||
});
|
||||
/**
|
||||
|
@ -496,7 +495,7 @@ Object.defineProperty(WebAudioSound.prototype, 'seek', {
|
|||
this.stopAndRemoveBufferSource();
|
||||
this.createAndStartBufferSource();
|
||||
}
|
||||
this.events.dispatch(new SoundValueEvent(this, 'SOUND_SEEK', value));
|
||||
this.emit('seek', this, value);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
var Class = require('../../utils/Class');
|
||||
var BaseSoundManager = require('../BaseSoundManager');
|
||||
var WebAudioSound = require('./WebAudioSound');
|
||||
var SoundValueEvent = require('../SoundValueEvent');
|
||||
|
||||
/*!
|
||||
* @author Pavle Goloskokovic <pgoloskokovic@gmail.com> (http://prunegames.com)
|
||||
*/
|
||||
|
@ -149,7 +149,7 @@ Object.defineProperty(WebAudioSoundManager.prototype, 'mute', {
|
|||
},
|
||||
set: function (value) {
|
||||
this.masterMuteNode.gain.setValueAtTime(value ? 0 : 1, 0);
|
||||
this.events.dispatch(new SoundValueEvent(this, 'SOUND_MUTE', value));
|
||||
this.emit('mute', value);
|
||||
}
|
||||
});
|
||||
/**
|
||||
|
@ -164,7 +164,7 @@ Object.defineProperty(WebAudioSoundManager.prototype, 'volume', {
|
|||
},
|
||||
set: function (value) {
|
||||
this.masterVolumeNode.gain.setValueAtTime(value, 0);
|
||||
this.events.dispatch(new SoundValueEvent(this, 'SOUND_VOLUME', value));
|
||||
this.emit('volume', value);
|
||||
}
|
||||
});
|
||||
module.exports = WebAudioSoundManager;
|
||||
|
|
Loading…
Add table
Reference in a new issue