Correct source checks in setEmitZone

This commit is contained in:
samme 2018-04-28 08:41:32 -07:00
parent 9a974514ff
commit 84ba1ba191

View file

@ -1571,29 +1571,30 @@ var ParticleEmitter = new Class({
var type = GetFastValue(zoneConfig, 'type', 'random'); var type = GetFastValue(zoneConfig, 'type', 'random');
var source = GetFastValue(zoneConfig, 'source', null); var source = GetFastValue(zoneConfig, 'source', null);
// TODO: if (source)
// For an EdgeZone, only source.getPoints(quantity, stepRate) is required.
// For a RandomZone, only source.getRandomPoint(point) is required.
// Any object implementing getPoint(position) could also be assigned here (instead of new EdgeZone, new RandomZone).
if (source && typeof source.getPoint === 'function')
{ {
switch (type) switch (type)
{ {
case 'random': case 'random':
this.emitZone = new RandomZone(source); if (typeof source.getRandomPoint === 'function')
{
this.emitZone = new RandomZone(source);
}
break; break;
case 'edge': case 'edge':
var quantity = GetFastValue(zoneConfig, 'quantity', 1); if (typeof source.getPoints === 'function')
var stepRate = GetFastValue(zoneConfig, 'stepRate', 0); {
var yoyo = GetFastValue(zoneConfig, 'yoyo', false); var quantity = GetFastValue(zoneConfig, 'quantity', 1);
var seamless = GetFastValue(zoneConfig, 'seamless', true); var stepRate = GetFastValue(zoneConfig, 'stepRate', 0);
var yoyo = GetFastValue(zoneConfig, 'yoyo', false);
var seamless = GetFastValue(zoneConfig, 'seamless', true);
this.emitZone = new EdgeZone(source, quantity, stepRate, yoyo, seamless); this.emitZone = new EdgeZone(source, quantity, stepRate, yoyo, seamless);
}
break; break;
} }