Version: stable
FUNCTION | |
---|---|
particlefx.play() | start playing a particle FX |
particlefx.stop() | stop playing a particle fx |
particlefx.set_constant() | set a shader constant for a particle FX component emitter |
particlefx.reset_constant() | reset a shader constant for a particle FX component emitter |
CONSTANT | |
---|---|
particlefx.EMITTER_STATE_SLEEPING | sleeping state |
particlefx.EMITTER_STATE_PRESPAWN | prespawn state |
particlefx.EMITTER_STATE_SPAWNING | spawning state |
particlefx.EMITTER_STATE_POSTSPAWN | postspawn state |
particlefx.play(url,[emitter_state_function])
particlefx.stop()
.
Which particle FX to play is identified by the URL.
A particle FX will continue to emit particles even if the game object the particle FX component belonged to is deleted. You can call particlefx.stop()
to stop it from emitting more particles.
PARAMETERS
url |
the particle fx that should start playing. |
[emitter_state_function] |
optional callback function that will be called when an emitter attached to this particlefx changes state.
|
EXAMPLES
How to play a particle fx when a game object is created. The callback receives the hash of the path to the particlefx, the hash of the id of the emitter, and the new state of the emitter as particlefx.EMITTER_STATE_local function emitter_state_change(self, id, emitter, state) if emitter == hash("exhaust") and state == particlefx.EMITTER_STATE_POSTSPAWN then -- exhaust is done spawning particles... end end function init(self) particlefx.play("#particlefx", emitter_state_change) end
particlefx.stop(url)
PARAMETERS
url |
the particle fx that should stop playing |
EXAMPLES
How to stop a particle fx when a game object is deleted:function final(self) particlefx.stop("#particlefx") end
particlefx.set_constant(url,emitter,constant,value)
PARAMETERS
url |
the particle FX that should have a constant set |
emitter |
the id of the emitter |
constant |
the name of the constant |
value |
the value of the constant |
EXAMPLES
The following examples assumes that the particle FX has id "particlefx", it contains an emitter with the id "emitter" and that the default-material in builtins is used, which defines the constant "tint". If you assign a custom material to the sprite, you can reset the constants defined there in the same manner. How to tint particles from an emitter red:function init(self) particlefx.set_constant("#particlefx", "emitter", "tint", vmath.vector4(1, 0, 0, 1)) end
particlefx.reset_constant(url,emitter,constant)
PARAMETERS
url |
the particle FX that should have a constant reset |
emitter |
the id of the emitter |
constant |
the name of the constant |
EXAMPLES
The following examples assumes that the particle FX has id "particlefx", it contains an emitter with the id "emitter" and that the default-material in builtins is used, which defines the constant "tint". If you assign a custom material to the sprite, you can reset the constants defined there in the same manner. How to reset the tinting of particles from an emitter:function init(self) particlefx.reset_constant("#particlefx", "emitter", "tint") end
sleeping state
The emitter does not have any living particles and will not spawn any particles in this state.
prespawn state
The emitter will be in this state when it has been started but before spawning any particles. Normally the emitter is in this state for a short time, depending on if a start delay has been set for this emitter or not.
spawning state
The emitter is spawning particles.
postspawn state
The emitter is not spawning any particles, but has particles that are still alive.