RandomZone uses a local vec2 now which allows it to work properly with Curves and Paths

This commit is contained in:
Richard Davey 2017-11-01 13:09:30 +00:00
parent ebca441d39
commit 77937f73c7
2 changed files with 17 additions and 3 deletions

View file

@ -606,7 +606,7 @@ var ParticleEmitter = new Class({
{
// Where source = Geom like Circle, or a Path or Curve
// emitZone: { type: 'random', source: X }
// emitZone: { type: 'edge', source: X, quantity: 32, [stepRate=0], [yoyo=false] }
// emitZone: { type: 'edge', source: X, quantity: 32, [stepRate=0], [yoyo=false], [seamless=true] }
var type = GetFastValue(zoneConfig, 'type', 'random');
var source = GetFastValue(zoneConfig, 'source', null);
@ -616,14 +616,20 @@ var ParticleEmitter = new Class({
switch (type)
{
case 'random':
this.emitZone = new RandomZone(source);
break;
case 'edge':
var quantity = GetFastValue(zoneConfig, 'quantity', 1);
var stepRate = GetFastValue(zoneConfig, 'stepRate', 0);
var yoyo = GetFastValue(zoneConfig, 'yoyo', false);
this.emitZone = new EdgeZone(source, quantity, stepRate, yoyo);
var seamless = GetFastValue(zoneConfig, 'seamless', true);
this.emitZone = new EdgeZone(source, quantity, stepRate, yoyo, seamless);
break;
}
}

View file

@ -1,4 +1,5 @@
var Class = require('../../../utils/Class');
var Vector2 = require('../../../math/Vector2');
var RandomZone = new Class({
@ -7,11 +8,18 @@ var RandomZone = new Class({
function RandomZone (source)
{
this.source = source;
this._tempVec = new Vector2();
},
getPoint: function (particle)
{
this.source.getRandomPoint(particle);
var vec = this._tempVec;
this.source.getRandomPoint(vec);
particle.x = vec.x;
particle.y = vec.y;
}
});