CPParticleEmitter

org.cosplay.CPParticleEmitter
abstract class CPParticleEmitter(id: String, tags: Set[String]) extends CPGameObject, 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.

Attributes

Example

See CPParticleExample class for the example of using particle effect.

Source
CPParticleEmitter.scala
Graph
Supertypes
trait CPAsset
class CPGameObject
class Object
trait Matchable
class Any
Known subtypes

Members list

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.

Attributes

Source
CPParticleEmitter.scala

Concrete methods

def isPaused: Boolean

Tests whether or not this emitter is paused.

Tests whether or not this emitter is paused.

Attributes

Source
CPParticleEmitter.scala
def pause(): Unit

Pause emission of the particles.

Pause emission of the particles.

Attributes

Source
CPParticleEmitter.scala
def reset(): Unit

Resets this emitter to its initial state.

Resets this emitter to its initial state.

Attributes

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.

Attributes

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.

Attributes

Source
CPParticleEmitter.scala

Inherited methods

override def equals(obj: Any): Boolean

Compares the receiver object (this) with the argument object (that) for equivalence.

Compares the receiver object (this) with the argument object (that) for equivalence.

Any implementation of this method should be an equivalence relation:

  • It is reflexive: for any instance x of type Any, x.equals(x) should return true.
  • It is symmetric: for any instances x and y of type Any, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any instances x, y, and z of type Any if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.

If you override this method, you should verify that your implementation remains an equivalence relation. Additionally, when overriding this method it is usually necessary to override hashCode to ensure that objects which are "equal" (o1.equals(o2) returns true) hash to the same scala.Int. (o1.hashCode.equals(o2.hashCode)).

Value parameters

that

the object to compare against this object for equality.

Attributes

Returns

true if the receiver object is equivalent to the argument; false otherwise.

Definition Classes
CPGameObject -> Any
Inherited from:
CPGameObject
Source
CPGameObject.scala
def getId: String

Gets unique ID of this game object.

Gets unique ID of this game object.

Attributes

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.

Attributes

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.

Attributes

Source
CPParticleEmitter.scala