Skip to content

Commit 77937f7

Browse files
committed
RandomZone uses a local vec2 now which allows it to work properly with Curves and Paths
1 parent ebca441 commit 77937f7

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

v3/src/gameobjects/particles/ParticleEmitter.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ var ParticleEmitter = new Class({
606606
{
607607
// Where source = Geom like Circle, or a Path or Curve
608608
// emitZone: { type: 'random', source: X }
609-
// emitZone: { type: 'edge', source: X, quantity: 32, [stepRate=0], [yoyo=false] }
609+
// emitZone: { type: 'edge', source: X, quantity: 32, [stepRate=0], [yoyo=false], [seamless=true] }
610610

611611
var type = GetFastValue(zoneConfig, 'type', 'random');
612612
var source = GetFastValue(zoneConfig, 'source', null);
@@ -616,14 +616,20 @@ var ParticleEmitter = new Class({
616616
switch (type)
617617
{
618618
case 'random':
619+
619620
this.emitZone = new RandomZone(source);
621+
620622
break;
621623

622624
case 'edge':
625+
623626
var quantity = GetFastValue(zoneConfig, 'quantity', 1);
624627
var stepRate = GetFastValue(zoneConfig, 'stepRate', 0);
625628
var yoyo = GetFastValue(zoneConfig, 'yoyo', false);
626-
this.emitZone = new EdgeZone(source, quantity, stepRate, yoyo);
629+
var seamless = GetFastValue(zoneConfig, 'seamless', true);
630+
631+
this.emitZone = new EdgeZone(source, quantity, stepRate, yoyo, seamless);
632+
627633
break;
628634
}
629635
}

v3/src/gameobjects/particles/zones/RandomZone.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
var Class = require('../../../utils/Class');
2+
var Vector2 = require('../../../math/Vector2');
23

34
var RandomZone = new Class({
45

@@ -7,11 +8,18 @@ var RandomZone = new Class({
78
function RandomZone (source)
89
{
910
this.source = source;
11+
12+
this._tempVec = new Vector2();
1013
},
1114

1215
getPoint: function (particle)
1316
{
14-
this.source.getRandomPoint(particle);
17+
var vec = this._tempVec;
18+
19+
this.source.getRandomPoint(vec);
20+
21+
particle.x = vec.x;
22+
particle.y = vec.y;
1523
}
1624

1725
});

0 commit comments

Comments
 (0)