Particle

Particle Object - Created automatically by Particle Emitters

Constructor

new Particle(position, tileInfo, angle, colorStart, colorEnd, lifeTime, sizeStart, sizeEnd, fadeRate, additive, trailScale, localSpaceEmitteropt, destroyCallbackopt)

Create a particle with the passed in settings Typically this is created automatically by a ParticleEmitter

Parameters:
NameTypeAttributesDescription
positionVector2

World space position of the particle

tileInfoTileInfo

Tile info to render particles

angleNumber

Angle to rotate the particle

colorStartColor

Color at start of life

colorEndColor

Color at end of life

lifeTimeNumber

How long to live for

sizeStartNumber

Size at start of life

sizeEndNumber

Size at end of life

fadeRateNumber

How quick to fade in/out

additiveBoolean

Does it use additive blend mode

trailScaleNumber

If a trail, how long to make it

localSpaceEmitterParticleEmitter<optional>

Parent emitter if local space

destroyCallbackfunction<optional>

Callback when particle dies

Extends

Members

additive

Properties
TypeDescription
Boolean

Is it additive

additiveColor

Properties
TypeDescription
Color

Additive color to apply when rendered

angle

Properties
TypeDescription
Number

Angle to rotate the object

angleDamping

Properties
NameTypeAttributesDefaultDescription
angleDampingNumber<optional>
objectDefaultAngleDamping

How much to slow down rotation each frame (0-1)

angleVelocity

Properties
TypeDescription
Number

Angular velocity of the object

children

Properties
TypeDescription
Array

List of children of this object

clampSpeedLinear

Properties
TypeDescription
Boolean

Limit object speed using linear or circular math

collideRaycast

Properties
TypeDescription
Boolean

Object collides with raycasts

collideSolidObjects

Properties
TypeDescription
Boolean

Object collides with solid objects

collideTiles

Properties
TypeDescription
Boolean

Object collides with the tile collision

color

Properties
TypeDescription
Color

Color to apply when rendered

colorEndDelta

Properties
TypeDescription
Color

Calculated change in color

colorStart

Properties
TypeDescription
Color

Color at start of life

damping

Properties
NameTypeAttributesDefaultDescription
dampingNumber<optional>
objectDefaultDamping

How much to slow down velocity each frame (0-1)

destroyCallback

Properties
TypeDescription
function

Called when particle dies

drawSize

Properties
TypeDescription
Vector2

Size of object used for drawing, uses size if not set

elasticity

Properties
NameTypeAttributesDefaultDescription
elasticityNumber<optional>
objectDefaultElasticity

How bouncy the object is when colliding (0-1)

fadeRate

Properties
TypeDescription
Number

How quick to fade in/out

friction

Properties
NameTypeAttributesDefaultDescription
frictionNumber<optional>
objectDefaultFriction

How much friction to apply when sliding (0-1)

gravityScale

Properties
TypeDescription
Number

How much to scale gravity by for this object

isSolid

Properties
TypeDescription
Boolean

Object collides with and blocks other objects

lifeTime

Properties
TypeDescription
Number

How long to live for

localAngle

Properties
TypeDescription
Number

Local angle if child

localPos

Properties
TypeDescription
Vector2

Local position if child

localSpaceEmitter

Properties
TypeDescription
ParticleEmitter

Parent emitter if local space

mass

Properties
NameTypeAttributesDefaultDescription
massNumber<optional>
objectDefaultMass

How heavy the object is, static if 0

mirror

Properties
TypeDescription
Boolean

Should it flip along y axis when rendered

parent

Properties
TypeDescription
EngineObject

Parent of object if in local space

pos

Properties
TypeDescription
Vector2

World space position of the object

renderOrder

Properties
TypeDescription
Number

Objects are sorted by render order

size

Properties
TypeDescription
Vector2

World space width and height of the object

sizeEndDelta

Properties
TypeDescription
Number

Calculated change in size

sizeStart

Properties
TypeDescription
Number

Size at start of life

spawnTime

Properties
TypeDescription
Number

Track when object was created

tileInfo

Properties
TypeDescription
TileInfo

Tile info to render object (undefined is untextured)

trailScale

Properties
TypeDescription
Number

If a trail, how long to make it

velocity

Properties
TypeDescription
Vector2

Velocity of the object

Methods

addChild(child, localPosopt, localAngleopt)

Attaches a child to this with a given local transform

Parameters:
NameTypeAttributesDefaultDescription
childEngineObject
localPosVector2<optional>
(0,0)
localAngleNumber<optional>
0

applyAcceleration(acceleration)

Apply acceleration to this object (adjust velocity, not affected by mass)

Parameters:
NameTypeDescription
accelerationVector2

applyForce(force)

Apply force to this object (adjust velocity, affected by mass)

Parameters:
NameTypeDescription
forceVector2

collideWithObject(object) → {Boolean}

Called to check if a object collision should be resolved

Parameters:
NameTypeDescription
objectEngineObject

the object to test against

Returns:
  • true if the collision should be resolved
Type: 
Boolean

collideWithTile(tileData, pos) → {Boolean}

Called to check if a tile collision should be resolved

Parameters:
NameTypeDescription
tileDataNumber

the value of the tile at the position

posVector2

tile where the collision occured

Returns:
  • true if the collision should be resolved
Type: 
Boolean

destroy()

Destroy this object, destroy it's children, detach it's parent, and mark it for removal

getAliveTime() → {Number}

How long since the object was created

Returns:
Type: 
Number

getMirrorSign() → {Number}

Get the direction of the mirror

Returns:

-1 if this.mirror is true, or 1 if not mirrored

Type: 
Number

localToWorld(pos)

Convert from local space to world space

Parameters:
NameTypeDescription
posVector2

local space point

localToWorldVector(vec)

Convert from local space to world space for a vector (rotation only)

Parameters:
NameTypeDescription
vecVector2

local space vector

removeChild(child)

Removes a child from this one

Parameters:
NameTypeDescription
childEngineObject

render()

Render the particle, automatically called each frame, sorted by renderOrder

renderDebugInfo()

Render debug info for this object

setCollision(collideSolidObjectsopt, isSolidopt, collideTilesopt, collideRaycastopt)

Set how this object collides

Parameters:
NameTypeAttributesDefaultDescription
collideSolidObjectsBoolean<optional>
true

Does it collide with solid objects?

isSolidBoolean<optional>
true

Does it collide with and block other objects? (expensive in large numbers)

collideTilesBoolean<optional>
true

Does it collide with the tile collision?

collideRaycastBoolean<optional>
true

Does it collide with raycasts?

toString() → {String}

Returns string containg info about this object for debugging

Returns:
Type: 
String

update()

Update the object physics, called automatically by engine once each frame

updateTransforms()

Update the object transform, called automatically by engine even when paused

worldToLocal(pos)

Convert from world space to local space

Parameters:
NameTypeDescription
posVector2

world space point

worldToLocalVector(vec)

Convert from world space to local space for a vector (rotation only)

Parameters:
NameTypeDescription
vecVector2

world space vector