ParticleEmitter
class ParticleEmitter extends Container
Particle Emitter Object.
Constructor
new ParticleEmitter(x: number, y: number, settings: ParticleEmitterSettings) → {}
// Create a particle emitter at position 100, 100
let emitter = new ParticleEmitter(100, 100, {
width: 16,
height : 16,
tint: "#f00",
totalParticles: 32,
angle: 0,
angleVariation: 6.283185307179586,
maxLife: 5,
speed: 3
});
// Add the emitter to the game world
me.game.world.addChild(emitter);
// Launch all particles one time and stop, like a explosion
emitter.burstParticles();
// Launch constantly the particles, like a fountain
emitter.streamParticles();
// At the end, remove emitter from the game world
// call this in onDestroyEvent function
me.game.world.removeChild(emitter);
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
x | number |
x position of the particle emitter |
||
y | number |
y position of the particle emitter |
||
settings | ParticleEmitterSettings |
<optional> |
ParticleEmitterSettings |
the settings for the particle emitter. |
Summary
Properties from ParticleEmitter
Methods from ParticleEmitter
|
|
number |
|
number |
|
boolean |
|
|
|
Stop the emitter from generating new particles (used only if emitter is Stream) |
|
|
Properties inherited from Container
boolean |
|
boolean |
|
Color |
|
boolean |
|
boolean |
|
boolean |
|
string |
|
Properties inherited from Renderable
number |
|
boolean |
|
Container | Entity |
|
ObservableVector2d |
|
boolean |
|
string |
|
Body |
|
Matrix2d |
|
number |
|
boolean |
|
string |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
Rect | RoundRect | Polygon | Line | Ellipse |
|
string |
|
Function |
|
ObservableVector3d |
|
GLShader |
|
Color |
|
boolean |
|
Properties inherited from Rect
Methods inherited from Container
Methods inherited from Renderable
Methods inherited from Rect
Rect |
|
Rect |
|
boolean |
|
Rect |
|
boolean |
|
boolean |
|
boolean |
|
Rect |
|
Rect |
|
Polygon |
|
Rect |
|
Methods inherited from Polygon
Array<number> |
|
boolean |
|
Polygon |
|
Polygon |
|
|
|
Polygon |
|
Polygon |
|
Polygon |
|
Public Properties
settings: ParticleEmitterSettings
ParticleEmitterSettings
the current (active) emitter settings
Public Methods
burstParticles(total: number) → {}
Launch all particles from emitter and stop (e.g. for explosion)
Name | Type | Attributes | Description |
---|---|---|---|
total | number |
<optional> |
number of particles to launch |
getRandomPointX() → {number}
returns a random point on the x axis within the bounds of this emitter
Type | Description |
---|---|
number |
getRandomPointY() → {number}
returns a random point on the y axis within the bounds this emitter
Type | Description |
---|---|
number |
isRunning() → {boolean}
Emitter is of type stream and is launching particles
Type | Description |
---|---|
boolean |
Emitter is Stream and is launching particles |
reset(settings: ParticleEmitterSettings) → {}
Reset the emitter with particle emitter settings.
Name | Type | Description |
---|---|---|
settings | ParticleEmitterSettings |
[optional] object with emitter settings. See ParticleEmitterSettings |
stopStream() → {}
Stop the emitter from generating new particles (used only if emitter is Stream)
streamParticles(duration: number) → {}
Launch particles from emitter constantly (e.g. for stream)
Name | Type | Attributes | Description |
---|---|---|---|
duration | number |
<optional> |
time that the emitter releases particles in ms |