You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Emitter now has minParticleAlpha and maxParticleAlpha values for setting a random alpha on emitted particles.
Emitter.particleAnchor allows you to control the anchor of emitted Particles. Defaults to 0.5 (same as before) but now under your control.
Emitter now emits Phaser.Particle objects instead of Phaser.Sprites, which can be extended as required.
Emitter has had various local properties removed that were already declared in Phaser.Group which it extends.
* @classdesc Create a new `Particle` object. Particles are extended Sprites that are emitted by a particle emitter.
11
+
*
12
+
* @constructor
13
+
* @extends Phaser.Sprite
14
+
* @param {Phaser.Game} game - A reference to the currently running game.
15
+
* @param {number} x - The x coordinate (in world space) to position the Sprite at.
16
+
* @param {number} y - The y coordinate (in world space) to position the Sprite at.
17
+
* @param {string|Phaser.RenderTexture|Phaser.BitmapData|PIXI.Texture} key - This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture.
18
+
* @param {string|number} frame - If this Sprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index.
@@ -44,13 +44,13 @@ Phaser.Particles.Arcade.Emitter = function (game, x, y, maxParticles) {
44
44
* @property {number} x - The X position of the top left corner of the emitter in world space.
45
45
* @default
46
46
*/
47
-
this.x=0;
47
+
// this.x = 0;
48
48
49
49
/**
50
50
* @property {number} y - The Y position of the top left corner of emitter in world space.
51
51
* @default
52
52
*/
53
-
this.y=0;
53
+
// this.y = 0;
54
54
55
55
/**
56
56
* @property {number} width - The width of the emitter. Particles can be randomly generated from anywhere within this box.
@@ -100,17 +100,29 @@ Phaser.Particles.Arcade.Emitter = function (game, x, y, maxParticles) {
100
100
*/
101
101
this.maxRotation=360;
102
102
103
+
/**
104
+
* @property {number} minParticleAlpha - The minimum possible alpha value of a particle.
105
+
* @default
106
+
*/
107
+
this.minParticleAlpha=1;
108
+
109
+
/**
110
+
* @property {number} maxParticleAlpha - The maximum possible alpha value of a particle.
111
+
* @default
112
+
*/
113
+
this.maxParticleAlpha=1;
114
+
103
115
/**
104
116
* @property {number} gravity - Sets the `body.gravity.y` of each particle sprite to this value on launch.
105
117
* @default
106
118
*/
107
119
this.gravity=100;
108
120
109
121
/**
110
-
* @property {any} particleClass - For emitting your own particle class types. They must extend Phaser.Sprite.
122
+
* @property {any} particleClass - For emitting your own particle class types. They must extend Phaser.Particle.
111
123
* @default
112
124
*/
113
-
this.particleClass=Phaser.Sprite;
125
+
this.particleClass=Phaser.Particle;
114
126
115
127
/**
116
128
* @property {Phaser.Point} particleDrag - The X and Y drag component of particles launched from the emitter.
@@ -136,10 +148,44 @@ Phaser.Particles.Arcade.Emitter = function (game, x, y, maxParticles) {
136
148
this.lifespan=2000;
137
149
138
150
/**
139
-
* @property {Phaser.Point} bounce - How much each particle should bounce on each axis. 1 = full bounce, 0 = no bounce.
151
+
* @property {Phaser.Point} bounce - How much each particle should bounce on each axis. 1 = full bounce, 0 = no bounce.
140
152
*/
141
153
this.bounce=newPhaser.Point();
142
154
155
+
/**
156
+
* @property {boolean} on - Determines whether the emitter is currently emitting particles. It is totally safe to directly toggle this.
157
+
* @default
158
+
*/
159
+
this.on=false;
160
+
161
+
/**
162
+
* @property {Phaser.Point} particleAnchor - When a particle is created its anchor will be set to match this Point object (defaults to x/y: 0.5 to aid in rotation)
163
+
* @default
164
+
*/
165
+
this.particleAnchor=newPhaser.Point(0.5,0.5);
166
+
167
+
/**
168
+
* @property {boolean} exists - Determines whether the emitter is being updated by the core game loop.
169
+
* @default
170
+
*/
171
+
// this.exists = true;
172
+
173
+
/**
174
+
* The point the particles are emitted from.
175
+
* Emitter.x and Emitter.y control the containers location, which updates all current particles
176
+
* Emitter.emitX and Emitter.emitY control the emission location relative to the x/y position.
177
+
* @property {number} emitX
178
+
*/
179
+
this.emitX=x;
180
+
181
+
/**
182
+
* The point the particles are emitted from.
183
+
* Emitter.x and Emitter.y control the containers location, which updates all current particles
184
+
* Emitter.emitX and Emitter.emitY control the emission location relative to the x/y position.
185
+
* @property {number} emitY
186
+
*/
187
+
this.emitY=y;
188
+
143
189
/**
144
190
* @property {number} _quantity - Internal helper for deciding how many particles to launch.
145
191
* @private
@@ -170,34 +216,6 @@ Phaser.Particles.Arcade.Emitter = function (game, x, y, maxParticles) {
170
216
*/
171
217
this._frames=null;
172
218
173
-
/**
174
-
* @property {boolean} on - Determines whether the emitter is currently emitting particles. It is totally safe to directly toggle this.
175
-
* @default
176
-
*/
177
-
this.on=false;
178
-
179
-
/**
180
-
* @property {boolean} exists - Determines whether the emitter is being updated by the core game loop.
181
-
* @default
182
-
*/
183
-
this.exists=true;
184
-
185
-
/**
186
-
* The point the particles are emitted from.
187
-
* Emitter.x and Emitter.y control the containers location, which updates all current particles
188
-
* Emitter.emitX and Emitter.emitY control the emission location relative to the x/y position.
189
-
* @property {boolean} emitX
190
-
*/
191
-
this.emitX=x;
192
-
193
-
/**
194
-
* The point the particles are emitted from.
195
-
* Emitter.x and Emitter.y control the containers location, which updates all current particles
196
-
* Emitter.emitX and Emitter.emitY control the emission location relative to the x/y position.
* @param {array|string} keys - A string or an array of strings that the particle sprites will use as their texture. If an array one is picked at random.
255
-
* @param {array|number} frames - A frame number, or array of frames that the sprite will use. If an array one is picked at random.
256
-
* @param {number} quantity - The number of particles to generate.
257
-
* @param {boolean} [collide=false] - Sets the checkCollision.none flag on the particle sprites body.
281
+
* @param {array|number} [frames=0] - A frame number, or array of frames that the sprite will use. If an array one is picked at random.
282
+
* @param {number} [quantity] - The number of particles to generate. If not given it will use the value of Emitter.maxParticles.
283
+
* @param {boolean} [collide=false] - If you want the particles to be able to collide with other Arcade Physics bodies then set this to true.
258
284
* @param {boolean} [collideWorldBounds=false] - A particle can be set to collide against the World bounds automatically and rebound back into the World if this is set to true. Otherwise it will leave the World.
259
285
* @return {Phaser.Particles.Arcade.Emitter} This Emitter instance.
260
286
*/
@@ -301,9 +327,7 @@ Phaser.Particles.Arcade.Emitter.prototype.makeParticles = function (keys, frames
301
327
302
328
particle.exists=false;
303
329
particle.visible=false;
304
-
305
-
// Center the origin for rotation assistance
306
-
particle.anchor.set(0.5);
330
+
particle.anchor.copyFrom(this.particleAnchor);
307
331
308
332
this.add(particle);
309
333
@@ -316,6 +340,7 @@ Phaser.Particles.Arcade.Emitter.prototype.makeParticles = function (keys, frames
316
340
317
341
/**
318
342
* Call this function to turn off all the particles and the emitter.
* Change the emitters center to match the center of any object with a `center` property, such as a Sprite.
569
+
* If the object doesn't have a center property it will be set to object.x + object.width / 2
570
+
*
520
571
* @method Phaser.Particles.Arcade.Emitter#at
521
-
* @param {object|Phaser.Sprite} object - The object that you wish to match the center with.
572
+
* @param {object|Phaser.Sprite|Phaser.Image|Phaser.TileSprite|Phaser.Text|PIXI.DisplayObject} object - The object that you wish to match the center with.
0 commit comments