Skip to content

Commit 77b335c

Browse files
committed
Added emitter follow support
1 parent aad5150 commit 77b335c

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

v3/src/gameobjects/particles/ParticleEmitter.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ var ParticleEmitter = new Class({
9797
this.easingFunctionScale = GetValue(config, 'scaleEase', GetEaseFunction('Linear'));
9898
this.easingFunctionRotation = GetValue(config, 'rotationEase', GetEaseFunction('Linear'));
9999

100+
this._follow = GetValue(config, 'follow', null);;
101+
100102
var frame = GetValue(config, 'frame', null);
101103

102104
if (frame)
@@ -105,6 +107,20 @@ var ParticleEmitter = new Class({
105107
}
106108
},
107109

110+
startFollow: function (gameObjectOrPoint)
111+
{
112+
this._follow = gameObjectOrPoint;
113+
114+
return this;
115+
},
116+
117+
stopFollow: function ()
118+
{
119+
this._follow = null;
120+
121+
return this;
122+
},
123+
108124
getFrame: function ()
109125
{
110126
if (this.frames.length === 1)
@@ -476,6 +492,13 @@ var ParticleEmitter = new Class({
476492
delta *= this.timeScale;
477493

478494
var step = (delta / 1000);
495+
496+
if (this._follow)
497+
{
498+
this.x = this._follow.x;
499+
this.y = this._follow.y;
500+
}
501+
479502
var particles = this.alive;
480503
var length = particles.length;
481504

0 commit comments

Comments
 (0)