2018-01-16 22:28:29 +00:00
|
|
|
var GameObjectCreator = require('../GameObjectCreator');
|
2017-11-17 13:30:29 +00:00
|
|
|
var GetFastValue = require('../../utils/object/GetFastValue');
|
2017-10-17 03:19:29 +00:00
|
|
|
var GetAdvancedValue = require('../../utils/object/GetAdvancedValue');
|
2017-11-08 18:14:14 +00:00
|
|
|
var ParticleEmitterManager = require('./ParticleEmitterManager');
|
2017-10-17 03:19:29 +00:00
|
|
|
|
|
|
|
// When registering a factory function 'this' refers to the GameObjectCreator context.
|
2017-11-17 13:30:29 +00:00
|
|
|
//
|
|
|
|
// There are several properties available to use:
|
|
|
|
//
|
|
|
|
// this.scene - a reference to the Scene that owns the GameObjectFactory
|
|
|
|
// this.displayList - a reference to the Display List the Scene owns
|
|
|
|
// this.updateList - a reference to the Update List the Scene owns
|
2017-10-17 03:19:29 +00:00
|
|
|
|
|
|
|
GameObjectCreator.register('particles', function (config)
|
|
|
|
{
|
|
|
|
var key = GetAdvancedValue(config, 'key', null);
|
|
|
|
var frame = GetAdvancedValue(config, 'frame', null);
|
2017-11-17 13:30:29 +00:00
|
|
|
var emitters = GetFastValue(config, 'emitters', null);
|
2017-10-17 03:19:29 +00:00
|
|
|
|
2017-11-17 13:30:29 +00:00
|
|
|
// frame is optional and can contain the emitters array or object if skipped
|
2017-11-08 18:14:14 +00:00
|
|
|
var manager = new ParticleEmitterManager(this.scene, key, frame, emitters);
|
2017-10-17 03:19:29 +00:00
|
|
|
|
2017-11-17 13:30:29 +00:00
|
|
|
var add = GetFastValue(config, 'add', false);
|
|
|
|
|
|
|
|
if (add)
|
|
|
|
{
|
|
|
|
this.displayList.add(manager);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.updateList.add(manager);
|
2017-10-17 03:19:29 +00:00
|
|
|
|
2017-11-08 18:14:14 +00:00
|
|
|
return manager;
|
2017-10-17 03:19:29 +00:00
|
|
|
});
|