Play an effect: a 2D emitter set to it, placed, scaled and recolored
- A continuous effect (fire, a torch) goes until destroyed or given an emitTime, a one-shot ends itself
- Any setting in the options replaces the effect's own for this play: {emitTime: .5} for a burst of a continuous
effect, {emitTime: 0, emitRate: 30} to keep a one-shot going, or speed, particleTime and the rest
- Attach it to an object with attach(emitter) to follow it, which keeps its angle, where addChild sets the angle
nameOrEffect string|ParticleEffectA built-in or added effect's name, or an effect
pos Vector2 optionaloptions ParticleEffectOptions optionalWhat to change for this play, each left out when not wanted:
scale grows the whole effect, the built-ins fit a one unit object at 1;
hue turns its colors around the color wheel, 1 is all the way;
saturation multiplies its saturation, 0 is gray;
angle is its direction, 0 is up, the effect's own angle when not given;
tileInfo, a TileInfo or a TextureInfo, is the game's own art to draw with in place of the effect's shape,
tinted by its colors, a whole texture drawn as one tile;
and any effect setting by its name, emitTime, emitRate, speed and the rest, replaces the effect's own
- Returns
- undefined when there is no such effect
Play an effect in 3D: a ParticleEmitter3D set to it, placed, scaled and recolored
- The same effect data as particleEffect, so the look carries across: a circle spawn area becomes a sphere and a
rectangle a box as deep as it is wide, both flat across the way it emits with options.flatten, a disc or a
sheet; a trail becomes a streak of the same length, and the settings the 3D emitter lacks (particleConeAngle,
randomColorLinear, velocityInheritance, localSpace) are left out; the stick behavior becomes the emitter's
stick, its grip where a particle lands
nameOrEffect string|ParticleEffectA built-in or added effect's name, or an effect
pos3D Vector3 optionaloptions ParticleEffectOptions optionalscale, hue, saturation, angle, tileInfo and any setting as particleEffect; angle turns it
about z, so 0 is up; flatten makes the spawn area flat across the way it emits; roundLighting lights each
particle as a ball, for smoke and clouds a light shines into
- Returns
- undefined when there is no such effect
Set a 2D emitter to an effect, live, so a running one keeps its particles
emitter ParticleEmittereffect ParticleEffect
Set a 3D emitter to an effect, live, so a running one keeps its particles; its place, scale and flatten stay
emitter ParticleEmitter3Deffect ParticleEffect
An effect with a 2D emitter's settings, to save, build again, or build in 3D with particleEffect3D; its tile is
left out, since a hand made emitter's tile is its own texture and not one an effect can name, and so are its
scale, which an effect does not keep: pass it again with options.scale, and its renderOrder, which an effect takes
from additive; a finished emitter's emit time is the time it emitted for
emitter ParticleEmittername string optional, default Effect
A copy of an effect with its four colors turned around the color wheel and their saturation scaled; lightness and
alpha stay, and gray and white have no hue to turn
effect ParticleEffecthue number optional, default 0How far around the wheel, 1 is all the way
saturation number optional, default 1Multiplies the saturation, 0 is gray, clamped to 1
Add effects to play by name, sanitized; one with the name of an effect already there replaces it, and one with no
settings takes every default
effects Array<ParticleEffectInput>|ParticleEffectInput
Add a behavior effects can use by name, or replace one
name stringupdate functionPushes a 2D particle, given the strength
update3D function optionalThe same for a 3D particle, none does nothing in 3D;
it replaces a behavior of the same name whole, its 3D push and range too
min number optionalStrength range the designer offers, and the range a strength is clamped to
max number optional, default 2value number optional, default 1Strength when first added
description string optional
Any input into a whole effect: missing fields take their defaults, bad ones are dropped or clamped
raw Object optional{name, settings, behaviors}, from a library file, the designer or code, checked as it
may be anything
The effect with a name, any case, undefined if there is none
name string
The tile of a built-in shape, on a sheet the plugin draws once; undefined headless, without a canvas or without
WebGL, where an effect draws untextured squares
name stringOne of particleEffectShapes
Load a library file the particle designer saved and add its effects
url string
- Returns
A library file, or one effect, into sanitized effects; throws on bad input
text string
The text of a library file with these effects, what particleEffectsLoad and the designer read
effects Array<ParticleEffect>
particleEffectBehaviors : Array<{name:string, update: (function()|undefined), update3D: (function()|undefined), min:number, max:number, value:number, description:string}>particleEffects.js:205The behaviors an effect can use, each a push applied to every particle every update, with a 2D and a 3D version
The groups the settings are in, in order
The names of the built-in effects, in the order a gallery shows them
particleEffectSettings : Array<{group:string, name:string, kind: ('number'|'checkbox'|'color'|'shape'), value: (number|boolean|string|Array<number>), min:number, max:number, step:number, description:string, hardMin:number, hardMax:number, extra:boolean}>particleEffects.js:29Every setting an effect has: its name, kind (number, checkbox, color or shape), default, the range the designer's
slider covers (min, max, step), the hard limits a typed value is clamped to, and whether it is set after the
emitter is made rather than passed to its constructor (extra)
Names of the shapes the plugin draws, for an effect's shape setting
An effect: what particleEffect plays, the designer edits and a library file holds; plain data, so it saves as JSON
name string optionalIts name, any case, 'Effect' when not given
settings ParticleEffectSettingsWhat it sets on an emitter, each one left out taking its default
behaviors Array<ParticleEffectBehavior> optionalPushes on every particle every update
A behavior an effect uses, by name, with how strong it is
name stringOne of particleEffectBehaviors, or one added with particleEffectsAddBehavior
strength number optionalHow strong, the behavior's own value when not given
The settings of an effect, each optional, the default when left out; colors are a Color or [r, g, b, a], and an
effect that comes back sanitized has them as channels; a test checks this list against particleEffectSettings
emitRate number optionalParticles per second, 0 emits none
emitTime number optionalSeconds to emit for, 0 is forever
emitSize number optionalDiameter, or width when rectangular
emitRect boolean optionalRectangle emitter, off is a circle
emitHeight number optionalRectangle height
emitConeAngle number optionalHalf angle particles move in, PI is all ways
angle number optionalEmitter angle, 0 points up
particleTime number optionalSeconds each particle lives
sizeStart number optionalSize at the start of life
sizeEnd number optionalSize at the end of life
fadeRate number optionalShare of life spent fading in and out
randomness number optionalHow much each particle varies
particleConeAngle number optionalHalf angle of start rotation, PI is any
trailScale number optionalStretch along the motion, 0 is off
additive boolean optionalGlow with additive blending
colorStartA Color|Array<number> optionalStart color, each particle picks between A and B
colorStartB Color|Array<number> optionalSecond start color
colorEndA Color|Array<number> optionalEnd color, each particle picks between A and B
colorEndB Color|Array<number> optionalSecond end color
randomColorLinear boolean optionalPick along A to B, off picks each channel
speed number optionalStart speed, world units per frame
angleSpeed number optionalSpin speed, radians per frame
damping number optionalSpeed kept each frame, 1 keeps it all
angleDamping number optionalSpin kept each frame
gravityScale number optionalHow much gravity pulls
gravity number optionalIts own fall each frame, the same in any game
velocityInheritance number optionalShare of emitter motion passed on
localSpace boolean optionalParticles move with the emitter
collideLevel boolean optionalHit tiles
restitution number optionalBounce when hitting tiles
friction number optionalSpeed kept sliding along tiles
shape string optionalBuilt-in shape: dot, soft, glow, smoke, spark, square, triangle, ring, star or
plus, '' uses the tile; any string, so a library read from JSON passes, a name it does not know drawing the
default
tileIndex number optionalTile in texture 0 when no shape, -1 is untextured
tileSize number optionalTile size in texture pixels
tilePadding number optionalPixels of padding around each tile
What a play of an effect can change: any setting, replacing the effect's own for this play, and scale, which grows
the whole effect, the built-ins fitting a one unit object at 1; hue, which turns its colors around the color wheel,
1 all the way; saturation, which multiplies it, 0 gray; angle, its direction, 0 up; tileInfo, the game's own art in
place of the shape, tinted by its colors, a TextureInfo drawn whole; and in 3D flatten, a flat spawn area across
the way it emits, and roundLighting, each particle lit as a ball, bright on the side toward each light; emitSize
may be a vec2, a rectangle; shape is one of the built-in names, so a misspelled one is caught, where an effect's
settings, read from JSON, take any string