ParticleActor API Reference


b5.ParticleActor

A ParticleActor is an Actor that can generate and display particles (a particle system), a particle can be actor of any kind, including another particle actor. To use a particle system actor you create an instance of ParticleActor then create and add individual actor particles, specifying a life span (the amount of time the particle exists), a spawn delay (the amount of time to wait before spawning the particle) and the total number of times the particle can be reborn. When a particle system has no particles left alive it will be destroyed. ParticleActor is derived from an Actor and inherits all properties, functions and so forth from its parent. A ParticleActor should be added to a Scene or another Actor once created in order for it to be processed.

Public properties

  • gravity – The amount of gravity to apply to particles within the system
  • onParticlesEnd() – This callback function is called when the particle actor runs out of particle
  • onParticleLost(particle) – This callback function is called each time a particle is about to be destroyed. Returning false will prevent the particle from being destroyed allowing it to be re-used

Additional particle properties

  • vo – Opacity velocity
  • vsx – X axis scale velocity
  • vsy – Y axis scale velocity

These properties are in addition to normal Actor properties

Methods

ParticleActor() – Creates an instance of a ParticleActor

resetParticle(actor) – Resets the particle to its initial spawn state (used internally)

addParticle(actor, life_span, num_lives, spawn_delay) – Adds an actor to the particle system as a particle

  • actor – The actor to add as a particle
  • life_span – The life span of the particle in seconds
  • num_lives – The number of times a particle will respawn before it is destroyed (0 for infinite)
  • spawn_delay – The number of seconds to wait before spawning this particle
  • Returns the created particle actor

update(dt) – Updates the actor, this method can be overriden by derived actors

  • dt – The amount of time that has passed since this actor was last updated

generateExplosion(count, type, duration, speed, spin_speed, rate, damping, properties) – Utility method that automatically generates an explosion type particle system

  • count – Total number of particles to create
  • type – The actor type of each particle created, for example b5.ArcActor or “ArcActor”
  • duration – The total duration of the particle system in seconds
  • speed – The speed at which the particles blow apart
  • spin_speed – The speed at which particles spin
  • rate – rate at which particles are created
  • damping – A factor to reduce velocity of particles each frame, values greater than 1 will increase velocities
  • properties – A collection of actor specific properties that will be assigned to each created particle

generatePlume(count, type, duration, speed, spin_speed, rate, damping, properties) - Utility method that automatically generates a smoke plume type particle system 

  • count – Total number of particles to create
  • type – The actor type of each particle created, for example b5.ArcActor or “ArcActor”
  • duration – The total duration of the particle system in seconds
  • speed – The speed at which the particles rise
  • spin_speed – The speed at which particles spin
  • rate – rate at which particles are created
  • damping – A factor to reduce velocity of particles each frame, values greater than 1 will increase velocities
  • properties – A collection of actor specific properties that will be assigned to each created particle

generateRain(count, type, duration, speed, spin_speed, rate, damping, width, properties) – Utility method that automatically generates weather effects such as rain

  • count – Total number of particles to create
  • type – The actor type of each particle created, for example b5.ArcActor or “ArcActor”
  • duration – The total duration of the particle system in seconds
  • speed – The speed at which the particles fall
  • spin_speed – The speed at which particles spin
  • rate – rate at which particles are created
  • damping – A factor to reduce velocity of particles each frame, values greater than 1 will increase velocities
  • width – The width of the area over which to generate particles
  • properties – A collection of actor specific properties that will be assigned to each created particle

Examples

Manual particle generation

Particle explosion example

Smoke plume particle example

 

615 total views, 1 views today