Class ParticleEmitter

Particle Emitter Object.

Hierarchy (view full)

Constructors

  • Parameters

    • x: number

      x position of the particle emitter

    • y: number

      y position of the particle emitter

    • Optionalsettings: {
          angle: number;
          angleVariation: number;
          blendMode: string;
          duration: number;
          floating: boolean;
          followTrajectory: boolean;
          framesToSkip: number;
          frequency: number;
          gravity: number;
          height: number;
          image: HTMLCanvasElement;
          maxEndScale: number;
          maxLife: number;
          maxParticles: number;
          maxRotation: number;
          maxStartScale: number;
          minEndScale: number;
          minLife: number;
          minRotation: number;
          minStartScale: number;
          onlyInViewport: boolean;
          speed: number;
          speedVariation: number;
          textureAdditive: boolean;
          textureSize: number;
          tint: string;
          totalParticles: number;
          width: number;
          wind: number;
      } = {}

      the settings for the particle emitter.

      • angle: number

        Start angle for particle launch in Radians

        angle

        Math.PI / 2
        

        ParticleEmitterSettings

      • angleVariation: number

        letiation in the start angle for particle launch in Radians.

        angleVariation

        0
        

        ParticleEmitterSettings

      • blendMode: string

        the blend mode to be applied when rendering particles. (note: this will superseed the textureAdditive setting if different than "normal")

        blendMode

        normal
        

        ParticleEmitterSettings

        • CanvasRenderer#setBlendMode
        • WebGLRenderer#setBlendMode
      • duration: number

        Duration that the emitter releases particles in ms (used only if emitter is Stream). After this period, the emitter stop the launch of particles.

        duration

        Infinity
        

        ParticleEmitterSettings

      • floating: boolean

        Render particles in screen space.

        floating

        false
        

        ParticleEmitterSettings

      • followTrajectory: boolean

        Update the rotation of particle in accordance the particle trajectory.
        The particle sprite should aim at zero angle (draw from left to right).
        Override the particle minRotation and maxRotation.

        followTrajectory

        false
        

        ParticleEmitterSettings

      • framesToSkip: number

        Skip n frames after updating the particle system once. This can be used to reduce the performance impact of emitters with many particles.

        framesToSkip

        0
        

        ParticleEmitterSettings

      • frequency: number

        How often a particle is emitted in ms (used only if emitter is a Stream).

        frequency

        100
        

        ParticleEmitterSettings

      • gravity: number

        Vertical force (Gravity) for each particle

        gravity

        0
        

        ParticleEmitterSettings

        game.world.gravity

      • height: number

        Height of the particle spawn area

        height

        ParticleEmitterSettings

        1
        
      • image: HTMLCanvasElement

        image used for particles texture (by default melonJS will create an white 8x8 texture image)

        image

        ParticleEmitterSettings

        undefined
        

        ParticleEmitterSettings.textureSize

      • maxEndScale: number

        Maximum end scale ratio for particles

        maxEndScale

        0
        

        ParticleEmitterSettings

      • maxLife: number

        Maximum time each particle lives once it is emitted in ms.

        maxLife

        3000
        

        ParticleEmitterSettings

      • maxParticles: number

        Maximum number of particles launched each time in this emitter (used only if emitter is Stream).

        maxParticles

        10
        

        ParticleEmitterSettings

      • maxRotation: number

        Maximum start rotation for particles sprites in Radians

        maxRotation

        0
        

        ParticleEmitterSettings

      • maxStartScale: number

        Maximum start scale ratio for particles (1 = no scaling)

        maxStartScale

        1
        

        ParticleEmitterSettings

      • minEndScale: number

        Minimum end scale ratio for particles

        minEndScale

        0
        

        ParticleEmitterSettings

      • minLife: number

        Minimum time each particle lives once it is emitted in ms.

        minLife

        1000
        

        ParticleEmitterSettings

      • minRotation: number

        Minimum start rotation for particles sprites in Radians

        minRotation

        0
        

        ParticleEmitterSettings

      • minStartScale: number

        Minimum start scale ratio for particles (1 = no scaling)

        minStartScale

        1
        

        ParticleEmitterSettings

      • onlyInViewport: boolean

        Update particles only in the viewport, remove it when out of viewport.

        onlyInViewport

        true
        

        ParticleEmitterSettings

      • speed: number

        Start speed of particles.

        speed

        2
        

        ParticleEmitterSettings

      • speedVariation: number

        letiation in the start speed of particles

        speedVariation

        1
        

        ParticleEmitterSettings

      • textureAdditive: boolean

        Enable the Texture Additive by composite operation ("additive" blendMode)

        textureAdditive

        false
        

        ParticleEmitterSettings

        ParticleEmitterSettings.blendMode

      • textureSize: number

        default texture size used for particles if no image is specified (by default melonJS will create an white 8x8 texture image)

        textureSize

        ParticleEmitterSettings

        8
        

        ParticleEmitterSettings.image

      • tint: string

        tint to be applied to particles

        tint

        ParticleEmitterSettings

        "#fff"
        
      • totalParticles: number

        Total number of particles in the emitter

        totalParticles

        50
        

        ParticleEmitterSettings

      • width: number

        Width of the particle spawn area.

        width

        ParticleEmitterSettings

        1
        
      • wind: number

        Horizontal force (like a Wind) for each particle

        wind

        0
        

        ParticleEmitterSettings

    Returns ParticleEmitter

    // Create a particle emitter at position 100, 100
    let emitter = new ParticleEmitter(100, 100, {
    width: 16,
    height : 16,
    tint: "#f00",
    totalParticles: 32,
    angle: 0,
    angleVariation: 6.283185307179586,
    maxLife: 5,
    speed: 3
    });

    // Add the emitter to the game world
    me.game.world.addChild(emitter);

    // Launch all particles one time and stop, like a explosion
    emitter.burstParticles();

    // Launch constantly the particles, like a fountain
    emitter.streamParticles();

    // At the end, remove emitter from the game world
    // call this in onDestroyEvent function
    me.game.world.removeChild(emitter);

Properties

GUID: string

(G)ame (U)nique (Id)entifier"
a GUID will be allocated for any renderable object added
to an object container (including the me.game.world container)

_absPos: undefined | object
_bounds: undefined | object
_defaultParticle: undefined | object
_dt: number
_flip: {
    x: boolean;
    y: boolean;
}
_inViewport: boolean
_parentApp: any
_tint: object
_updateCount: number
alpha: number

Define the renderable opacity
Set to zero if you do not wish an object to be drawn

  • Renderable#setOpacity
  • Renderable#getOpacity
1.0
alwaysUpdate: boolean

Whether the renderable object will always update, even when outside of the viewport

false
ancestor: Container | Entity

a reference to the parent object that contains this renderable

undefined
anchorPoint: ObservableVector2d

The anchor point is used for attachment behavior, and/or when applying transformations.
The coordinate system places the origin at the top left corner of the frame (0, 0) and (1, 1) means the bottom-right corner

a Renderable's anchor point defaults to (0.5,0.5), which corresponds to the center position.

Note: Object created through Tiled will have their anchorPoint set to (0, 0) to match Tiled Level editor implementation. To specify a value through Tiled, use a json expression like json:{"x":0.5,"y":0.5}.

<0.5,0.5>
autoDepth: boolean

Specify if the children z index should automatically be managed by the parent container

true
autoSort: boolean

Specify if the children list should be automatically sorted when adding a new child

true
autoTransform: boolean

When enabled, an object container will automatically apply any defined transformation before calling the child draw method.

true
// enable "automatic" transformation when the object is activated
onActivateEvent: function () {
// reset the transformation matrix
this.currentTransform.identity();
// ensure the anchor point is the renderable center
this.anchorPoint.set(0.5, 0.5);
// enable auto transform
this.autoTransform = true;
....
}
backgroundColor: Color

define a background color for this container

(0, 0, 0, 0.0)
// add a red background color to this container
this.backgroundColor.setColor(255, 0, 0);
blendMode: string

the blend mode to be applied to this renderable (see renderer setBlendMode for available blend mode)

"normal"
  • CanvasRenderer#setBlendMode
  • WebGLRenderer#setBlendMode
body: Body

the renderable physic body

// define a new Player Class
class PlayerEntity extends me.Sprite {
// constructor
constructor(x, y, settings) {
// call the parent constructor
super(x, y , settings);

// define a basic walking animation
this.addAnimation("walk", [...]);
// define a standing animation (using the first frame)
this.addAnimation("stand", [...]);
// set the standing animation as default
this.setCurrentAnimation("stand");

// add a physic body
this.body = new me.Body(this);
// add a default collision shape
this.body.addShape(new me.Rect(0, 0, this.width, this.height));
// configure max speed, friction, and initial force to be applied
this.body.setMaxVelocity(3, 15);
this.body.setFriction(0.4, 0);
this.body.force.set(3, 0);
this.isKinematic = false;

// set the display to follow our position on both axis
me.game.viewport.follow(this.pos, me.game.viewport.AXIS.BOTH);
}

...

}
clipping: boolean

Specify if the container draw operation should clip his children to its own bounds

false
currentTransform: Matrix2d

the renderable default transformation matrix

enableChildBoundsUpdate: boolean

Specify if the container bounds should automatically take in account all child bounds when updated (this is expensive and disabled by default, only enable if necessary)

false
floating: boolean

If true, this renderable will be rendered using screen coordinates, as opposed to world coordinates. Use this, for example, to define UI elements.

false
isDirty: boolean

when true the renderable will be redrawn during the next update cycle

true
isKinematic: boolean

If true then physic collision and input events will not impact this renderable

true
isPersistent: boolean

make the renderable object persistent over level changes

false
mask:
    | Rect
    | Polygon
    | Line
    | Ellipse
    | RoundRect

A mask limits rendering elements to the shape and position of the given mask object. So, if the renderable is larger than the mask, only the intersecting part of the renderable will be visible.

undefined
// apply a mask in the shape of a Star
myNPCSprite.mask = new me.Polygon(myNPCSprite.width / 2, 0, [
// draw a star
{x: 0, y: 0},
{x: 14, y: 30},
{x: 47, y: 35},
{x: 23, y: 57},
{x: 44, y: 90},
{x: 0, y: 62},
{x: -44, y: 90},
{x: -23, y: 57},
{x: -47, y: 35},
{x: -14, y: 30}
]);
name: string

The name of the renderable

""
onChildChange: (() => void)

a callback to be extended, triggered after a child has been added or removed

onVisibilityChange: Function

an event handler that is called when the renderable leave or enter a camera viewport

undefined
this.onVisibilityChange = function(inViewport) {
if (inViewport === true) {
console.log("object has entered the in a camera viewport!");
}
};
points: Vector2d[]

Array of points defining the Polygon
Note: If you manually change points, you must call recalcafterwards so that the changes get applied correctly.

origin point of the Polygon

root: boolean

whether the container is the root of the scene

false
settings: {
    angle: number;
    angleVariation: number;
    blendMode: string;
    duration: number;
    floating: boolean;
    followTrajectory: boolean;
    framesToSkip: number;
    frequency: number;
    gravity: number;
    height: number;
    image: HTMLCanvasElement;
    maxEndScale: number;
    maxLife: number;
    maxParticles: number;
    maxRotation: number;
    maxStartScale: number;
    minEndScale: number;
    minLife: number;
    minRotation: number;
    minStartScale: number;
    onlyInViewport: boolean;
    speed: number;
    speedVariation: number;
    textureAdditive: boolean;
    textureSize: number;
    tint: string;
    totalParticles: number;
    width: number;
    wind: number;
}

the current (active) emitter settings

Type declaration

  • angle: number

    Start angle for particle launch in Radians

    angle

    Math.PI / 2
    

    ParticleEmitterSettings

  • angleVariation: number

    letiation in the start angle for particle launch in Radians.

    angleVariation

    0
    

    ParticleEmitterSettings

  • blendMode: string

    the blend mode to be applied when rendering particles. (note: this will superseed the textureAdditive setting if different than "normal")

    blendMode

    normal
    

    ParticleEmitterSettings

    • CanvasRenderer#setBlendMode
    • WebGLRenderer#setBlendMode
  • duration: number

    Duration that the emitter releases particles in ms (used only if emitter is Stream). After this period, the emitter stop the launch of particles.

    duration

    Infinity
    

    ParticleEmitterSettings

  • floating: boolean

    Render particles in screen space.

    floating

    false
    

    ParticleEmitterSettings

  • followTrajectory: boolean

    Update the rotation of particle in accordance the particle trajectory.
    The particle sprite should aim at zero angle (draw from left to right).
    Override the particle minRotation and maxRotation.

    followTrajectory

    false
    

    ParticleEmitterSettings

  • framesToSkip: number

    Skip n frames after updating the particle system once. This can be used to reduce the performance impact of emitters with many particles.

    framesToSkip

    0
    

    ParticleEmitterSettings

  • frequency: number

    How often a particle is emitted in ms (used only if emitter is a Stream).

    frequency

    100
    

    ParticleEmitterSettings

  • gravity: number

    Vertical force (Gravity) for each particle

    gravity

    0
    

    ParticleEmitterSettings

    game.world.gravity

  • height: number

    Height of the particle spawn area

    height

    ParticleEmitterSettings

    1
    
  • image: HTMLCanvasElement

    image used for particles texture (by default melonJS will create an white 8x8 texture image)

    image

    ParticleEmitterSettings

    undefined
    

    ParticleEmitterSettings.textureSize

  • maxEndScale: number

    Maximum end scale ratio for particles

    maxEndScale

    0
    

    ParticleEmitterSettings

  • maxLife: number

    Maximum time each particle lives once it is emitted in ms.

    maxLife

    3000
    

    ParticleEmitterSettings

  • maxParticles: number

    Maximum number of particles launched each time in this emitter (used only if emitter is Stream).

    maxParticles

    10
    

    ParticleEmitterSettings

  • maxRotation: number

    Maximum start rotation for particles sprites in Radians

    maxRotation

    0
    

    ParticleEmitterSettings

  • maxStartScale: number

    Maximum start scale ratio for particles (1 = no scaling)

    maxStartScale

    1
    

    ParticleEmitterSettings

  • minEndScale: number

    Minimum end scale ratio for particles

    minEndScale

    0
    

    ParticleEmitterSettings

  • minLife: number

    Minimum time each particle lives once it is emitted in ms.

    minLife

    1000
    

    ParticleEmitterSettings

  • minRotation: number

    Minimum start rotation for particles sprites in Radians

    minRotation

    0
    

    ParticleEmitterSettings

  • minStartScale: number

    Minimum start scale ratio for particles (1 = no scaling)

    minStartScale

    1
    

    ParticleEmitterSettings

  • onlyInViewport: boolean

    Update particles only in the viewport, remove it when out of viewport.

    onlyInViewport

    true
    

    ParticleEmitterSettings

  • speed: number

    Start speed of particles.

    speed

    2
    

    ParticleEmitterSettings

  • speedVariation: number

    letiation in the start speed of particles

    speedVariation

    1
    

    ParticleEmitterSettings

  • textureAdditive: boolean

    Enable the Texture Additive by composite operation ("additive" blendMode)

    textureAdditive

    false
    

    ParticleEmitterSettings

    ParticleEmitterSettings.blendMode

  • textureSize: number

    default texture size used for particles if no image is specified (by default melonJS will create an white 8x8 texture image)

    textureSize

    ParticleEmitterSettings

    8
    

    ParticleEmitterSettings.image

  • tint: string

    tint to be applied to particles

    tint

    ParticleEmitterSettings

    "#fff"
    
  • totalParticles: number

    Total number of particles in the emitter

    totalParticles

    50
    

    ParticleEmitterSettings

  • width: number

    Width of the particle spawn area.

    width

    ParticleEmitterSettings

    1
    
  • wind: number

    Horizontal force (like a Wind) for each particle

    wind

    0
    

    ParticleEmitterSettings

settings

ParticleEmitter

shader: GLShader

(Experimental) an optional shader, to be used instead of the default built-in one, when drawing this renderable (WebGL only)

undefined
sortOn: string

The property of the child object that should be used to sort on this container value : "x", "y", "z"

"z"
type: string

the shape type (used internally)

"Polygon"
updateWhenPaused: boolean

Whether to update this object when the game is paused.

false

Accessors

  • get inViewport(): boolean
  • Whether the renderable object is visible and within the viewport

    Returns boolean

    false
    
  • set inViewport(value): void
  • Parameters

    • value: boolean

    Returns void

  • get isFlippedX(): boolean
  • returns true if this renderable is flipped on the horizontal axis

    Returns boolean

    Renderable#flipX

  • get isFlippedY(): boolean
  • returns true if this renderable is flipped on the vertical axis

    Returns boolean

    Renderable#flipY

  • get isFloating(): boolean
  • Whether the renderable object is floating (i.e. used screen coordinates), or contained in a floating parent container

    Returns boolean

    Renderable#floating

  • get parentApp(): Application
  • returns the parent application (or game) to which this renderable is attached to

    Returns Application

    the parent application or undefined if not attached to any container/app

  • get tint(): Color
  • define a tint for this renderable. a (255, 255, 255) r, g, b value will remove the tint effect.

    Returns Color

    (255, 255, 255)
    
    // add a red tint to this renderable
    this.tint.setColor(255, 128, 128);
    // remove the tint
    this.tint.setColor(255, 255, 255);
  • set tint(value): void
  • Parameters

    Returns void

Methods

  • Add a child to the container
    if auto-sort is disable, the object will be appended at the bottom of the list. Adding a child to the container will automatically remove it from its other container. Meaning a child can only have one parent. This is important if you add a renderable to a container then add it to the World container it will move it out of the orginal container. Then when the World container reset() method is called the renderable will not be in any container.
    if the given child implements a onActivateEvent method, that method will be called once the child is added to this container.

    Parameters

    • child: any

      Child to be added

    • Optionalz: number

      forces the z index of the child to the specified value

    Returns Renderable

    the added child

  • Launch all particles from emitter and stop (e.g. for explosion)

    Parameters

    • Optionaltotal: number

      number of particles to launch

    Returns void

  • center the rectangle position around the given coordinates

    Parameters

    • x: number

      the x coordinate around which to center this rectangle

    • y: number

      the y coordinate around which to center this rectangle

    Returns Rect

    this rectangle

  • Returns true if the rectangle contains the given point or rectangle

    Parameters

    • Rest...args: any

    Returns boolean

    True if the rectangle contain the given point or rectangle, otherwise false

    if (rect.contains(10, 10)) {
    // do something
    }
    // or
    if (rect.contains(myVector2d)) {
    // do something
    }
    if (rect.contains(myRect)) {
    // do something
    }
  • The forEach() method executes a provided function once per child element.
    the callback function is invoked with three arguments:

    • The current element being processed in the array
    • The index of element in the array.
    • The array forEach() was called upon.

    Parameters

    • callback: Function

      fnction to execute on each element

    • OptionalthisArg: object

      value to use as this(i.e reference Object) when executing callback.

    Returns void

    // iterate through all children of this container
    container.forEach((child) => {
    // do something with the child
    child.doSomething();
    });
    container.forEach((child, index) => { ... });
    container.forEach((child, index, array) => { ... });
    container.forEach((child, index, array) => { ... }, thisArg);
  • return the child corresponding to the specified GUID
    note : avoid calling this function every frame since it parses the whole object list each time

    Parameters

    • guid:
          | string
          | number
          | boolean
          | RegExp

      child GUID

    Returns Renderable

    corresponding child or null

  • returns the list of childs with the specified name
    as defined in Tiled (Name field of the Object Properties)
    note : avoid calling this function every frame since it parses the whole object list each time

    Parameters

    • name:
          | string
          | number
          | boolean
          | RegExp

      child name

    Returns Renderable[]

    Array of children

  • return the child corresponding to the given property and value.
    note : avoid calling this function every frame since it parses the whole object tree each time

    Parameters

    • prop: string

      Property name

    • value:
          | string
          | number
          | boolean
          | RegExp

      Value of the property

    Returns Renderable[]

    Array of childs

    // get the first child object called "mainPlayer" in a specific container :
    let ent = myContainer.getChildByProp("name", "mainPlayer");

    // or query the whole world :
    let ent = container.getChildByProp("name", "mainPlayer");

    // partial property matches are also allowed by using a RegExp.
    // the following matches "redCOIN", "bluecoin", "bagOfCoins", etc :
    let allCoins = container.getChildByProp("name", /coin/i);

    // searching for numbers or other data types :
    let zIndex10 = container.getChildByProp("z", 10);
    let inViewport = container.getChildByProp("inViewport", true);
  • returns a list of indices for all triangles defined in this polygon

    Returns number[]

    an array of vertex indices for all triangles forming this polygon.

  • returns a random point on the x axis within the bounds of this emitter

    Returns number

  • returns a random point on the y axis within the bounds this emitter

    Returns number

  • Returns true if the vertices composing this polygon form a convex shape (vertices must be in clockwise order).

    Returns boolean

    true if the vertices are convex, false if not, null if not computable

  • determines whether all coordinates of this rectangle are finite numbers.

    Returns boolean

    false if all coordinates are positive or negative Infinity or NaN; otherwise, true.

  • Emitter is of type stream and is launching particles

    Returns boolean

    Emitter is Stream and is launching particles

  • onCollision callback, triggered in case of collision, when this renderable body is colliding with another one

    Returns boolean

    true if the object should respond to the collision (its position and velocity will be corrected)

    // colision handler
    onCollision(response) {
    if (response.b.body.collisionType === me.collision.types.ENEMY_OBJECT) {
    // makes the other object solid, by substracting the overlap vector to the current position
    this.pos.sub(response.overlapV);
    this.hurt();
    // not solid
    return false;
    }
    // Make the object solid
    return true;
    },
  • Prepare the rendering context before drawing (automatically called by melonJS). This will apply any defined transforms, anchor point, tint or blend mode and translate the context accordingly to this renderable position.

    Parameters

    Returns void

    • Renderable#draw
    • Renderable#postDraw
  • Removes (and optionally destroys) a child from the container.
    (removal is immediate and unconditional)
    Never use keepalive=true with objects from pool. Doing so will create a memory leak.

    Parameters

    • child: any

      Child to be removed

    • Optionalkeepalive: boolean

      True to prevent calling child.destroy()

    Returns void

  • Reset the emitter with particle emitter settings.

    Parameters

    • settings: {
          angle: number;
          angleVariation: number;
          blendMode: string;
          duration: number;
          floating: boolean;
          followTrajectory: boolean;
          framesToSkip: number;
          frequency: number;
          gravity: number;
          height: number;
          image: HTMLCanvasElement;
          maxEndScale: number;
          maxLife: number;
          maxParticles: number;
          maxRotation: number;
          maxStartScale: number;
          minEndScale: number;
          minLife: number;
          minRotation: number;
          minStartScale: number;
          onlyInViewport: boolean;
          speed: number;
          speedVariation: number;
          textureAdditive: boolean;
          textureSize: number;
          tint: string;
          totalParticles: number;
          width: number;
          wind: number;
      } = {}

      [optional] object with emitter settings. See ParticleEmitterSettings

      • angle: number

        Start angle for particle launch in Radians

        angle

        Math.PI / 2
        

        ParticleEmitterSettings

      • angleVariation: number

        letiation in the start angle for particle launch in Radians.

        angleVariation

        0
        

        ParticleEmitterSettings

      • blendMode: string

        the blend mode to be applied when rendering particles. (note: this will superseed the textureAdditive setting if different than "normal")

        blendMode

        normal
        

        ParticleEmitterSettings

        • CanvasRenderer#setBlendMode
        • WebGLRenderer#setBlendMode
      • duration: number

        Duration that the emitter releases particles in ms (used only if emitter is Stream). After this period, the emitter stop the launch of particles.

        duration

        Infinity
        

        ParticleEmitterSettings

      • floating: boolean

        Render particles in screen space.

        floating

        false
        

        ParticleEmitterSettings

      • followTrajectory: boolean

        Update the rotation of particle in accordance the particle trajectory.
        The particle sprite should aim at zero angle (draw from left to right).
        Override the particle minRotation and maxRotation.

        followTrajectory

        false
        

        ParticleEmitterSettings

      • framesToSkip: number

        Skip n frames after updating the particle system once. This can be used to reduce the performance impact of emitters with many particles.

        framesToSkip

        0
        

        ParticleEmitterSettings

      • frequency: number

        How often a particle is emitted in ms (used only if emitter is a Stream).

        frequency

        100
        

        ParticleEmitterSettings

      • gravity: number

        Vertical force (Gravity) for each particle

        gravity

        0
        

        ParticleEmitterSettings

        game.world.gravity

      • height: number

        Height of the particle spawn area

        height

        ParticleEmitterSettings

        1
        
      • image: HTMLCanvasElement

        image used for particles texture (by default melonJS will create an white 8x8 texture image)

        image

        ParticleEmitterSettings

        undefined
        

        ParticleEmitterSettings.textureSize

      • maxEndScale: number

        Maximum end scale ratio for particles

        maxEndScale

        0
        

        ParticleEmitterSettings

      • maxLife: number

        Maximum time each particle lives once it is emitted in ms.

        maxLife

        3000
        

        ParticleEmitterSettings

      • maxParticles: number

        Maximum number of particles launched each time in this emitter (used only if emitter is Stream).

        maxParticles

        10
        

        ParticleEmitterSettings

      • maxRotation: number

        Maximum start rotation for particles sprites in Radians

        maxRotation

        0
        

        ParticleEmitterSettings

      • maxStartScale: number

        Maximum start scale ratio for particles (1 = no scaling)

        maxStartScale

        1
        

        ParticleEmitterSettings

      • minEndScale: number

        Minimum end scale ratio for particles

        minEndScale

        0
        

        ParticleEmitterSettings

      • minLife: number

        Minimum time each particle lives once it is emitted in ms.

        minLife

        1000
        

        ParticleEmitterSettings

      • minRotation: number

        Minimum start rotation for particles sprites in Radians

        minRotation

        0
        

        ParticleEmitterSettings

      • minStartScale: number

        Minimum start scale ratio for particles (1 = no scaling)

        minStartScale

        1
        

        ParticleEmitterSettings

      • onlyInViewport: boolean

        Update particles only in the viewport, remove it when out of viewport.

        onlyInViewport

        true
        

        ParticleEmitterSettings

      • speed: number

        Start speed of particles.

        speed

        2
        

        ParticleEmitterSettings

      • speedVariation: number

        letiation in the start speed of particles

        speedVariation

        1
        

        ParticleEmitterSettings

      • textureAdditive: boolean

        Enable the Texture Additive by composite operation ("additive" blendMode)

        textureAdditive

        false
        

        ParticleEmitterSettings

        ParticleEmitterSettings.blendMode

      • textureSize: number

        default texture size used for particles if no image is specified (by default melonJS will create an white 8x8 texture image)

        textureSize

        ParticleEmitterSettings

        8
        

        ParticleEmitterSettings.image

      • tint: string

        tint to be applied to particles

        tint

        ParticleEmitterSettings

        "#fff"
        
      • totalParticles: number

        Total number of particles in the emitter

        totalParticles

        50
        

        ParticleEmitterSettings

      • width: number

        Width of the particle spawn area.

        width

        ParticleEmitterSettings

        1
        
      • wind: number

        Horizontal force (like a Wind) for each particle

        wind

        0
        

        ParticleEmitterSettings

    Returns void

  • scale the renderable around his anchor point. Scaling actually applies changes to the currentTransform member wich is used by the renderer to scale the object when rendering. It does not scale the object itself. For example if the renderable is an image, the image.width and image.height properties are unaltered but the currentTransform member will be changed.

    Parameters

    • x: number

      a number representing the abscissa of the scaling vector.

    • Optionaly: number = x

      a number representing the ordinate of the scaling vector.

    Returns Renderable

    Reference to this object for method chaining

  • Automatically set the specified property of all childs to the given value

    Parameters

    • prop: string

      property name

    • value: object

      property value

    • Optionalrecursive: boolean

      recursively apply the value to child containers if true

    Returns void

  • set new value to the rectangle shape

    Parameters

    • x: number

      position of the Rectangle

    • y: number

      position of the Rectangle

    • w: number | Vector2d[]

      width of the rectangle, or an array of vector defining the rectangle

    • Optionalh: number

      height of the rectangle, if a numeral width parameter is specified

    • Rest...args: any

    Returns Rect

    this rectangle

  • Shifts the Polygon to the given position vector.

    Parameters

    • Rest...args: any

    Returns void

    polygon.shift(10, 10);
    // or
    polygon.shift(myVector2d);
  • Manually trigger the sort of all the childs in the container

    Parameters

    • Optionalrecursive: boolean

      recursively sort all containers if true

    Returns void

  • Stop the emitter from generating new particles (used only if emitter is Stream)

    Returns void

  • Launch particles from emitter constantly (e.g. for stream)

    Parameters

    • Optionalduration: number

      time that the emitter releases particles in ms

    Returns void

  • translate the Polygon by the specified offset

    Parameters

    • Rest...args: any

    Returns Polygon

    Reference to this object for method chaining

    polygon.translate(10, 10);
    // or
    polygon.translate(myVector2d);
  • update the bounding box for this container.

    Parameters

    • Optionalabsolute: boolean = true

      update the bounds size and position in (world) absolute coordinates

    Returns Bounds

    this container bounding box Rectangle object