Class: Emitter

Grape2D. Emitter

new Emitter(options)

Emits particles to the particle system.
Parameters:
Name Type Description
options Object Setup properties.
Properties
Name Type Argument Description
position Grape2D.Vector Position of the emitter, and initial position of the particles.
velocity Grape2D.Vector Initial velocity of the particles.The length of the vector indicated its speed. The angle indicates the angle.
speedVariation number <optional>
Variation of the length of the velocity vector. So that particles created have a speed between velocity.length-speedVariation and velocity.length+speedVariation.
spread number <optional>
Spread of particles relative to the velocity angle. It should be in radius.
particleLife number Life of a particle in milliseconds.
particleLifeVariation number <optional>
Life variation of particles created, relative to the life property.
maxParticles number <optional>
Maximum number of particles that this emitter can have, dead or alive. Because the particles are instantiated at construction time.
rate number <optional>
Rate of particles emitted, per second.
Source:

Members

<private> maxParticles :number

Emitter maximum particles.
Type:
  • number
Source:

<private> mrate :number

Rate of particles to emit per millisecond.
Type:
  • number
Source:

<private> particleLife :number

Life of particles.
Type:
  • number
Source:

<private> particleLifeVariation :number

Life variation of particles.
Type:
  • number
Source:

<private> particles :!Array.<!Grape2D.Particle>

Particles of the emitter.
Type:
Source:

<private> particleSystem :Grape2D.ParticleSystem

Particle system associated with this emitter.
Type:
Source:

<private> position :Grape2D.Vector

Position of the emitter and initial position of newly created or revived particles.
Type:
Source:

<private> rate :number

Rate of particles to emit per second.
Type:
  • number
Source:

<private> renderedParticles :number

Number of particle rendered after each render cycle.
Type:
  • number
Source:

<private> speedVariation :number

Speed variation of created or revived particles.
Type:
  • number
Source:

<private> spread :number

Spread of the particles, in relation to the velocity vector.
Type:
  • number
Source:

<private> vAngle :number

Cached value, of the velocity angle.
Type:
  • number
Source:

<private> velocity :Grape2D.Vector

Initial velocity of the particles.
Type:
Source:

<private> vMagnitude :number

Cached value, of the magnitude of the velocity.
Type:
  • number
Source:

Methods

<protected> createParticles()

Create particles. Up to the maximum number of particles of the emitter.
Source:

getParticleLife() → {number}

Gets the particle life of the created particles.
Source:
Returns:
Particle life.
Type
number

getParticleLifeVariation() → {number}

Gets the particle life variation of the created particles, relative to the particle life.
Source:
Returns:
Particle life variation.
Type
number

getParticles() → {!Array.<!Grape2D.Particle>}

Gets the particles associated with this emitter, they can be either dead or alive.
Source:
Returns:
Particles.
Type
!Array.<!Grape2D.Particle>

getParticleSystem() → {Grape2D.ParticleSystem}

Gets the particle system associated with this emitter.
Source:
Returns:
Particle system.
Type
Grape2D.ParticleSystem

getPosition() → {Grape2D.Vector}

Gets the position of the emitter.
Source:
Returns:
Position of the emitter.
Type
Grape2D.Vector

getRate() → {number}

Gets the rate that the emitter emits particles.
Source:
Returns:
Emission rate.
Type
number

getRenderedParticles() → {number}

Gets the number of particles rendered in the last call to the Grape2D.Emitter.render method.
Source:
Returns:
Number of particles rendered.
Type
number

getSpeedVariation() → {number}

Gets the speed variation of the created particles.
Source:
Returns:
Speed variation.
Type
number

getSpread() → {number}

Gets the spread of the created particles, relative to the velocity vector angle.
Source:
Returns:
Spread of the created particles.
Type
number

getVelocity() → {Grape2D.Vector}

Gets the velocity of the emitter.
Source:
Returns:
Velocity of the emitter.
Type
Grape2D.Vector

render(renderer, camera)

Renders the particles into a renderer.
Parameters:
Name Type Description
renderer Grape2D.Renderer Renderer.
camera Grape2D.Camera Camera.
Source:

<protected> reviveParticle(particle)

Revives a particle according to the emitter properties.
Parameters:
Name Type Description
particle Grape2D.Particle Particle to revive.
Source:

setParticleLife(particleLife)

Sets the particle life of the created particles.
Parameters:
Name Type Description
particleLife number Particle life.
Source:

setParticleLifeVariation(particleLifeVariation)

Sets the particle life variation of the created particles, relative to the particle life.
Parameters:
Name Type Description
particleLifeVariation number Particle life variation.
Source:

setParticleSystem(ps)

Sets the particle system associated with this emitter.
Parameters:
Name Type Description
ps Grape2D.ParticleSystem Particle system.
Source:

setPosition(position)

Sets the position of the emitter.
Parameters:
Name Type Description
position Grape2D.Vector Position of the emitter.
Source:

setRate(rate)

Sets the rate that the emitter emits particles.
Parameters:
Name Type Description
rate number Emission rate.
Source:

setSpeedVariation(speedVariation)

Sets the speed variation of the created particles.
Parameters:
Name Type Description
speedVariation number Speed variation.
Source:

setSpread(spread)

Sets the spread of the created particles, relative to the velocity vector angle.
Parameters:
Name Type Description
spread number Spread of the created particles.
Source:

setVelocity(velocity)

Sets the velocity of the emitter.
Parameters:
Name Type Description
velocity Grape2D.Vector Velocity of the emitter.
Source:

update(dt, scene)

Updates an emitter. If there are particles dead, it revives them according to the rate specified. The emitter should have a particle system associated, if this method is to be called, it could be done through emitter.setParticleSystem(particleSystem);
Parameters:
Name Type Description
dt number Time elapsed since the last update.
scene Grape2D.Scene Scene of the emitter.
Source: