Constructor
new ParticleEmitter(position, angleopt, emitSizeopt, emitTimeopt, emitRateopt, emitConeAngleopt, tileInfoopt, colorStartAopt, colorStartBopt, colorEndAopt, colorEndBopt, particleTimeopt, sizeStartopt, sizeEndopt, speedopt, angleSpeedopt, dampingopt, angleDampingopt, gravityScaleopt, particleConeAngleopt, fadeRateopt, randomnessopt, collideTilesopt, additiveopt, randomColorLinearopt, renderOrderopt, localSpaceopt)
Create a particle system with the given settings
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
position | Vector2 | World space position of the emitter | ||
angle | number | <optional> | Angle to emit the particles | |
emitSize | number | | <optional> | 0 | World space size of the emitter (float for circle diameter, vec2 for rect) |
emitTime | number | <optional> | 0 | How long to stay alive (0 is forever) |
emitRate | number | <optional> | 100 | How many particles per second to spawn, does not emit if 0 |
emitConeAngle | number | <optional> | PI | Local angle to apply velocity to particles from emitter |
tileInfo | TileInfo | <optional> | Tile info to render particles (undefined is untextured) | |
colorStartA | Color | <optional> | WHITE | Color at start of life 1, randomized between start colors |
colorStartB | Color | <optional> | WHITE | Color at start of life 2, randomized between start colors |
colorEndA | Color | <optional> | CLEAR_WHITE | Color at end of life 1, randomized between end colors |
colorEndB | Color | <optional> | CLEAR_WHITE | Color at end of life 2, randomized between end colors |
particleTime | number | <optional> | 0.5 | How long particles live |
sizeStart | number | <optional> | 0.1 | How big are particles at start |
sizeEnd | number | <optional> | 1 | How big are particles at end |
speed | number | <optional> | 0.1 | How fast are particles when spawned |
angleSpeed | number | <optional> | 0.05 | How fast are particles rotating |
damping | number | <optional> | 1 | How much to dampen particle speed |
angleDamping | number | <optional> | 1 | How much to dampen particle angular speed |
gravityScale | number | <optional> | 0 | How much gravity effect particles |
particleConeAngle | number | <optional> | Cone for start particle angle | |
fadeRate | number | <optional> | 0.1 | How quick to fade particles at start/end in percent of life |
randomness | number | <optional> | 0.2 | Apply extra randomness percent |
collideTiles | boolean | <optional> | false | Do particles collide against tiles |
additive | boolean | <optional> | false | Should particles use additive blend |
randomColorLinear | boolean | <optional> | true | Should color be randomized linearly or across each component |
renderOrder | number | <optional> | Render order for particles (additive is above other stuff by default) | |
localSpace | boolean | <optional> | false | Should it be in local space of emitter (world space is default) |
- Source
// create a particle emitter
let pos = vec2(2,3);
let particleEmitter = new ParticleEmitter
(
pos, 0, 1, 0, 500, PI, // pos, angle, emitSize, emitTime, emitRate, emitCone
tile(0, 16), // tileInfo
rgb(1,1,1,1), rgb(0,0,0,1), // colorStartA, colorStartB
rgb(1,1,1,0), rgb(0,0,0,0), // colorEndA, colorEndB
1, .2, .2, .1, .05, // particleTime, sizeStart, sizeEnd, particleSpeed, particleAngleSpeed
.99, 1, 1, PI, .05, // damping, angleDamping, gravityScale, particleCone, fadeRate,
.5, 1 // randomness, collide, additive, randomColorLinear, renderOrder
);
Extends
- EngineObject
Members
additive
PropertiesType | Description |
---|---|
boolean | Should particles use additive blend |
- Source
angleDamping
PropertiesType | Description |
---|---|
number | How much to dampen particle angular speed |
- Source
angleSpeed
PropertiesType | Description |
---|---|
number | How fast are particles rotating |
- Source
collideTiles
PropertiesType | Description |
---|---|
boolean | Do particles collide against tiles |
- Source
colorEndA
PropertiesType | Description |
---|---|
Color | Color at end of life 1, randomized between end colors |
- Source
colorEndB
PropertiesType | Description |
---|---|
Color | Color at end of life 2, randomized between end colors |
- Source
colorStartA
PropertiesType | Description |
---|---|
Color | Color at start of life 1, randomized between start colors |
- Source
colorStartB
PropertiesType | Description |
---|---|
Color | Color at start of life 2, randomized between start colors |
- Source
damping
PropertiesType | Description |
---|---|
number | How much to dampen particle speed |
- Source
emitConeAngle
PropertiesType | Description |
---|---|
number | Local angle to apply velocity to particles from emitter |
- Source
emitRate
PropertiesType | Description |
---|---|
number | How many particles per second to spawn, does not emit if 0 |
- Source
emitSize
PropertiesType | Description |
---|---|
number | | World space size of the emitter (float for circle diameter, vec2 for rect) |
- Source
emitTime
PropertiesType | Description |
---|---|
number | How long to stay alive (0 is forever) |
- Source
emitTimeBuffer
PropertiesType | Description |
---|---|
number | Track particle emit time |
- Source
fadeRate
PropertiesType | Description |
---|---|
number | How quick to fade in particles at start/end in percent of life |
- Source
gravityScale
PropertiesType | Description |
---|---|
number | How much gravity affects particles |
- Source
localSpace
PropertiesType | Description |
---|---|
boolean | Should it be in local space of emitter |
- Source
particleConeAngle
PropertiesType | Description |
---|---|
number | Cone for start particle angle |
- Source
particleCreateCallback
PropertiesType | Description |
---|---|
ParticleCallbackFunction | Callback when particle is created |
- Source
particleDestroyCallback
PropertiesType | Description |
---|---|
ParticleCallbackFunction | Callback when particle is destroyed |
- Source
particleTime
PropertiesType | Description |
---|---|
number | How long particles live |
- Source
randomColorLinear
PropertiesType | Description |
---|---|
boolean | Should color be randomized linearly or across each component |
- Source
randomness
PropertiesType | Description |
---|---|
number | Apply extra randomness percent |
- Source
sizeEnd
PropertiesType | Description |
---|---|
number | How big are particles at end |
- Source
sizeStart
PropertiesType | Description |
---|---|
number | How big are particles at start |
- Source
speed
PropertiesType | Description |
---|---|
number | How fast are particles when spawned |
- Source
trailScale
PropertiesType | Description |
---|---|
number | If non zero the particle is drawn as a trail, stretched in the direction of velocity |
- Source
velocityInheritance
PropertiesType | Description |
---|---|
number | Percentage of velocity to pass to particles (0-1) |
- Source
Methods
emitParticle() → {Particle}
Spawn one particle
- Source
- Type:
- Particle
update()
Update the emitter to spawn particles, called automatically by engine once each frame
- Source