Class Index | File Index

Classes


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.

Particles should be simple objects which don't need to perform many calculations before being drawn. All particles are rendered in world coordinates to speed up processing.

A word of caution: Using a particle engine will potentially slow down your frame rate depending on the amount of particles per frame. While care has been taken to make the particle engine run as fast as possible, it is not uncommon to see a significant drop in frame rate when using a lot of particles.

You can modify the maximum number of particles the engine will allow with the 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.

Class Summary
Constructor Attributes Constructor Name and Description
 
Create a particle engine
Method Summary
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 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
 
Releases the particle engine back into the pool.
 
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
Class Detail
R.particles.ParticleEngine()
Create a particle engine
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.

Documentation generated by JsDoc Toolkit 2.4.0 on Mon Mar 18 2013 16:09:19 GMT-0400 (EDT)