CPParticleEmitter

abstract class CPParticleEmitter(id: String, tags: Set[String]) extends CPGameObject with CPAsset

Particle emitter.

Particle emitter is part of the particle effect animation support. Particle effect support consists of three key components:

Particle defines a single-pixel element (a-la mini-sprite) that has its own lifecycle and gets updated on each frame update. Particle emitter is a components that is responsible for creating particles. And particle sprite ties all that together into single renderable component. Particle sprite can have one or more particle emitters and each emitter can create multiple particles. One of the key features of particle effect support is its modularity: particle implementation can be reused by multiple emitters, and an emitter implementation can be reused by multiple independent particle sprites.

Particle emitter is an asset. Just like other assets such as fonts, images, animations or videos they are not managed or governed by the CosPlay game engine unlike scenes and scene objects that are managed and governed by the game engine. Assets are typically created outside the game loop and managed by the developer, they can be freely shared between scenes or scene objects as any other standard Scala objects.

Value parameters:
id

Unique ID of this emitter. By default, a random 6-character ID will be used.

tags

Optional set of organizational tags. These tags are here only for the game developer benefits as they are not used by the game engine itself. By default, the empty set is used.

Example:

See CPParticleExample class for the example of using particle effect.

Source:
CPParticleEmitter.scala
trait CPAsset
class Object
trait Matchable
class Any

Value members

Abstract methods

def emit(ctx: CPBaseContext): Iterable[CPParticle]

Gets collections of particles that constitutes a particle emission for this frame update. Note that this method is called on each frame update by the particle sprite.

Gets collections of particles that constitutes a particle emission for this frame update. Note that this method is called on each frame update by the particle sprite.

Value parameters:
ctx

Emission context.

Source:
CPParticleEmitter.scala

Concrete methods

def isPaused: Boolean

Tests whether or not this emitter is paused.

Tests whether or not this emitter is paused.

Source:
CPParticleEmitter.scala
def pause(): Unit

Pause emission of the particles.

Pause emission of the particles.

Source:
CPParticleEmitter.scala
def reset(): Unit

Resets this emitter to its initial state.

Resets this emitter to its initial state.

Source:
CPParticleEmitter.scala
def resume(reset: Boolean): Unit

Resumes emission of the particles.

Resumes emission of the particles.

Value parameters:
reset

Whether or not to reset this emitter before resuming emission.

Source:
CPParticleEmitter.scala
def toggle(): Unit

Toggles pause status of this emitter. Note that with this method you don't have the control of resetting the emitter before resuming its emission.

Toggles pause status of this emitter. Note that with this method you don't have the control of resetting the emitter before resuming its emission.

Source:
CPParticleEmitter.scala

Inherited methods

override def equals(obj: Any): Boolean
Definition Classes
Inherited from:
CPGameObject
Source:
CPGameObject.scala
def getId: String

Gets unique ID of this game object.

Gets unique ID of this game object.

Inherited from:
CPGameObject
Source:
CPGameObject.scala
def getTags: Set[String]

Gets optional set of organizational tags. Note that by default the set of tags is empty.

Gets optional set of organizational tags. Note that by default the set of tags is empty.

See also:
Inherited from:
CPGameObject
Source:
CPGameObject.scala

Concrete fields

override val getOrigin: String

Gets the origin of this asset. Typically, this should be a URL, file name or class name for in-code assets like array images, animations or system font.

Gets the origin of this asset. Typically, this should be a URL, file name or class name for in-code assets like array images, animations or system font.

Source:
CPParticleEmitter.scala