Fork me on GitHub
View source

package com.haxepunk.graphics

class Emitter


extends Graphic

Particle emitter used for emitting and rendering particle sprites. Good rendering performance with large amounts of particles.

Constructor

View source

new (source : ImageOrTileType, frameWidth : Int = 0, frameHeight : Int = 0) : Void

Constructor. Sets the source image to use for newly added particle types.


Parameters:
source   

Source image.

frameWidth   

Frame width.

frameHeight   

Frame height.

Variables

read only particleCount : Int

Amount of currently existing particles.

scale : Float

smooth : Bool

Functions

View source

clear () : Void

Clears all particles.


Available since:

2.5.2

View source

emit (name : String, x : Float = 0, y : Float = 0, angle : Float = 0) : Particle

Emits a particle.


Parameters:
name   

Particle type to emit.

x   

X point to emit from.

y   

Y point to emit from.

angle   

Base angle to start from.


Returns:

The Particle emited.

View source

emitInCircle (name : String, x : Float, y : Float, radius : Float) : Particle

Randomly emits the particle inside the specified radius


Parameters:
name   

Particle type to emit.

x   

X point to emit from.

y   

Y point to emit from.

radius   

Radius to emit inside.


Returns:

The Particle emited.

View source

emitInRectangle (name : String, x : Float, y : Float, width : Float, height : Float) : Particle

Randomly emits the particle inside the specified area


Parameters:
name   

Particle type to emit

x   

X point to emit from.

y   

Y point to emit from.

width   

Width of the area to emit from.

height   

height of the area to emit from.


Returns:

The Particle emited.

View source

newType (name : String, ?frames : Array<Int>) : ParticleType

Creates a new Particle type for this Emitter.


Parameters:
name   

Name of the particle type.

frames   

Array of frame indices for the particles to animate.


Returns:

A new ParticleType object.

View source

render (target : BitmapData, point : Point, camera : Point) : Void

View source

renderAtlas (layer : Int, point : Point, camera : Point) : Void

View source

setAlpha (name : String, start : Float = 1, finish : Float = 0, ease : EaseFunction) : ParticleType

Sets the alpha range of the particle type.


Parameters:
name   

The particle type.

start   

The starting alpha.

finish   

The finish alpha.

ease   

Optional easer function.


Returns:

This ParticleType object.

View source

setColor (name : String, start : Int = 0xFFFFFF, finish : Int = 0, ease : EaseFunction) : ParticleType

Sets the color range of the particle type.


Parameters:
name   

The particle type.

start   

The starting color.

finish   

The finish color.

ease   

Optional easer function.


Returns:

This ParticleType object.

View source

setGravity (name : String, gravity : Float = 0, gravityRange : Float = 0) : ParticleType

Sets the gravity range for a particle type.


Parameters:
name   

The particle type.

gravity   

Gravity amount to affect to the particle y velocity.

gravityRange   

Random amount to add to the particle's gravity.


Returns:

This ParticleType object.

View source

setMotion (name : String, angle : Float, distance : Float, duration : Float, angleRange : Float = 0, distanceRange : Float = 0, durationRange : Float = 0, ease : EaseFunction, backwards : Bool = false) : ParticleType

Defines the motion range for a particle type.


Parameters:
name   

The particle type.

angle   

Launch Direction.

distance   

Distance to travel.

duration   

Particle duration.

angleRange   

Random amount to add to the particle's direction.

distanceRange   

Random amount to add to the particle's distance.

durationRange   

Random amount to add to the particle's duration.

ease   

Optional ease function.

backwards   

If the motion should be played backwards.


Returns:

This ParticleType object.

View source

setRotation (name : String, startAngle : Float, spanAngle : Float, startAngleRange : Float = 0, spanAngleRange : Float = 0, ?ease : EaseFunction) : ParticleType

Defines the rotation range for a particle type.


Parameters:
name   

The particle type.

startAngle   

Starting angle.

spanAngle   

Total amount of degrees to rotate.

startAngleRange   

Random amount to add to the particle's starting angle.

spanAngleRange   

Random amount to add to the particle's span angle.

ease   

Optional easer function.


Returns:

This ParticleType object.


Available since:

2.6.0

View source

setScale (name : String, start : Float = 1, finish : Float = 0, ease : EaseFunction) : ParticleType

Sets the scale range of the particle type.


Parameters:
name   

The particle type.

start   

The starting scale.

finish   

The finish scale.

ease   

Optional easer function.


Returns:

This ParticleType object.


Available since:

2.6.0

View source

setSource (source : ImageOrTileType, frameWidth : Int = 0, frameHeight : Int = 0) : Void

Changes the source image to use for newly added particle types.


Parameters:
source   

Source image.

frameWidth   

Frame width.

frameHeight   

Frame height.

View source

setTrail (name : String, length : Int = 1, delay : Float = 0.1, alpha : Float = 1) : ParticleType

Sets the trail of the particle type.


Parameters:
name   

The particle type.

length   

Number of trailing particles to draw.

delay   

Time to delay each trailing particle, in seconds.

alpha   

Multiply each successive trail particle's alpha by this amount.


Returns:

This ParticleType object.


Available since:

2.6.0

View source

update () : Void