|
1 | | -var BuildGameObject = require('../BuildGameObject'); |
2 | 1 | var GameObjectCreator = require('../../scene/plugins/GameObjectCreator'); |
| 2 | +var GetFastValue = require('../../utils/object/GetFastValue'); |
3 | 3 | var GetAdvancedValue = require('../../utils/object/GetAdvancedValue'); |
4 | 4 | var ParticleEmitterManager = require('./ParticleEmitterManager'); |
5 | 5 |
|
6 | 6 | // When registering a factory function 'this' refers to the GameObjectCreator context. |
| 7 | +// |
| 8 | +// There are several properties available to use: |
| 9 | +// |
| 10 | +// this.scene - a reference to the Scene that owns the GameObjectFactory |
| 11 | +// this.displayList - a reference to the Display List the Scene owns |
| 12 | +// this.updateList - a reference to the Update List the Scene owns |
7 | 13 |
|
8 | 14 | GameObjectCreator.register('particles', function (config) |
9 | 15 | { |
10 | 16 | var key = GetAdvancedValue(config, 'key', null); |
11 | 17 | var frame = GetAdvancedValue(config, 'frame', null); |
12 | | - var emitters = GetAdvancedValue(config, 'emitters', null); |
| 18 | + var emitters = GetFastValue(config, 'emitters', null); |
13 | 19 |
|
| 20 | + // frame is optional and can contain the emitters array or object if skipped |
14 | 21 | var manager = new ParticleEmitterManager(this.scene, key, frame, emitters); |
15 | 22 |
|
16 | | - BuildGameObject(this.scene, manager, config); |
| 23 | + var add = GetFastValue(config, 'add', false); |
| 24 | + |
| 25 | + if (add) |
| 26 | + { |
| 27 | + this.displayList.add(manager); |
| 28 | + } |
| 29 | + |
| 30 | + this.updateList.add(manager); |
17 | 31 |
|
18 | 32 | return manager; |
19 | 33 | }); |
0 commit comments