Class R.particles.ParticleEngine
Extends
R.engine.BaseObject.
The particle engine is a system for updating and expiring
particles within a game environment. This is registered with the
render context so it will be updated at regular intervals. The maximum
number of supported particles can be configured, but defaults to 250.
It is possible to run multiple particle engines within a render context.
R.Engine.options["maxParticles"]
setting. Each
browser has been tailored for the best performance, but this values
can be changed in your game with either #setMaximum or by
changing the engine option.
Defined in: particleengine.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Create a particle engine
|
Method Attributes | Method Name and Description |
---|---|
addEffect(particleEffect)
Run a particle effect
|
|
addParticle(particle)
Add a single particle to the engine.
|
|
addParticles(particles)
Add a group of particles at one time.
|
|
destroy()
Destroy the particle engine and all contained particles
|
|
Get the class name of this object
|
|
Get the maximum number of particles allowed in the particle engine.
|
|
Get the properties object for the particle engine
|
|
release()
Releases the particle engine back into the pool.
|
|
reset()
Reset the particle engine.
|
|
setMaximum(maximum)
Set the absolute maximum number of particles the engine will allow.
|
|
update(renderContext, time, dt)
Update the particles within the render context, and for the specified time.
|
- Methods borrowed from class R.engine.BaseObject:
- addEvent, addEvents, getElement, jQ, removeEvent, setElement, triggerEvent
- Methods borrowed from class R.engine.PooledObject:
- clearObjectDataModel, getId, getName, getObjectDataModel, isDestroyed, setName, setObjectDataModel, toString, toXML
Method Detail
{R.particles.Effect}
addEffect(particleEffect)
Run a particle effect
- Parameters:
- particleEffect
- Returns:
- {R.particles.Effect} The instance of the effect
addParticle(particle)
Add a single particle to the engine. If many particles are being
added at one time, use #addParticles instead to add a
R.struct.Container of particles.
- Parameters:
- particle
- {R.particles.AbstractParticle} A particle to animate
addParticles(particles)
Add a group of particles at one time. This reduces the number of calls
to #addParticle which resorts the array of particles each time.
- Parameters:
- particles
- {Array|R.struct.Container} A container of particles to add at one time
destroy()
Destroy the particle engine and all contained particles
{String}
getClassName()
Get the class name of this object
- Returns:
- {String} "R.particles.ParticleEngine"
{Number}
getMaximum()
Get the maximum number of particles allowed in the particle engine.
- Returns:
- {Number}
{Object}
getProperties()
Get the properties object for the particle engine
- Returns:
- {Object}
release()
Releases the particle engine back into the pool.
reset()
Reset the particle engine. Destroys all active particles and effects.
setMaximum(maximum)
Set the absolute maximum number of particles the engine will allow. The
engine is configured with a maximum number in
R.Engine.options["maxParticles"]
.
You can override this value using configurations also.
- Parameters:
- maximum
- {Number} The maximum particles the particle engine allows
update(renderContext, time, dt)
Update the particles within the render context, and for the specified time.
- Parameters:
- renderContext
- {R.rendercontexts.AbstractRenderContext} The context the particles will be rendered within.
- time
- {Number} The global time within the engine.
- dt
- {Number} The delta between the world time and the last time the world was updated in milliseconds.