Class R.particles.Emitter
Extends
R.engine.PooledObject.
Particle emitter class. Emits particles at a regular
interval as long as it is active. The function that is passed to generate
the particles will be called with three arguments: an offset position, the
current world time, and the delta from when the last frame was drawn. The function
can either return a single particle or an Array
of particles.
Within the scope of the function, "this" refers to the R.particles.Emitter
object.
// Create the particle emitter which returns the type of particle // we want to emit. 5 is the delay between particle emissions and // 350 is the life of the particle (both in milliseconds) var emitter = R.particles.Emitter.create(function(offset) { // Create a particle return FuseParticle.create(offset, 350); }, 5); // Assign the emitter to the particle engine which will draw it emitter.setParticleEngine(Tutorial13.pEngine);
Defined in: emitter.js.
Constructor Attributes | Constructor Name and Description |
---|---|
R.particles.Emitter(emitFunc, interval, active)
Create a particle emitter
|
Method Attributes | Method Name and Description |
---|---|
Get the class name of this object
|
|
Return the interval at which particles are emitted.
|
|
isActive()
Method to check if the emitter is active.
|
|
release()
Release the particle back into the pool.
|
|
setActive(state)
Set the active state of the particle emitter
|
|
setInterval(interval)
Set the interval at which particles are emitted.
|
|
setParticleEngine(particleEngine)
Set the particle engine the particle emitter should emit particles to.
|
- Methods borrowed from class R.engine.PooledObject:
- clearObjectDataModel, destroy, getId, getName, getObjectDataModel, getProperties, isDestroyed, setName, setObjectDataModel, toString, toXML
Class Detail
R.particles.Emitter(emitFunc, interval, active)
Create a particle emitter
- Parameters:
- emitFunc
- {Function} A function that emits new particles.
- interval
- {Number} The time between emissions
- active Optional
- {Boolean} A flag indicating whether the emitter should emit particles
Method Detail
{String}
getClassName()
Get the class name of this object
- Returns:
- {String} "R.particles.Emitter"
{Number}
getInterval()
Return the interval at which particles are emitted.
- Returns:
- {Number}
{Boolean}
isActive()
Method to check if the emitter is active.
- Returns:
- {Boolean}
release()
Release the particle back into the pool.
setActive(state)
Set the active state of the particle emitter
- Parameters:
- state
- {Boolean}
true
to enable emission of particles,false
to disable emission.
setInterval(interval)
Set the interval at which particles are emitted.
- Parameters:
- interval
- {Number} The number of milliseconds between emissions
setParticleEngine(particleEngine)
Set the particle engine the particle emitter should emit particles to.
- Parameters:
- particleEngine
- {R.particles.ParticleEngine}