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
Name | Type | Attributes | Description |
---|---|---|---|
position | Vector2 | World space position of the particle | |
tileInfo | TileInfo | Tile info to render particles | |
angle | Number | Angle to rotate the particle | |
colorStart | Color | Color at start of life | |
colorEnd | Color | Color at end of life | |
lifeTime | Number | How long to live for | |
sizeStart | Number | Size at start of life | |
sizeEnd | Number | Size at end of life | |
fadeRate | Number | How quick to fade in/out | |
additive | Boolean | Does it use additive blend mode | |
trailScale | Number | If a trail, how long to make it | |
localSpaceEmitter | ParticleEmitter | <optional> | Parent emitter if local space |
destroyCallback | function | <optional> | Callback when particle dies |
- Source
Extends
Members
additive
PropertiesType | Description |
---|---|
Boolean | Is it additive |
- Source
additiveColor
PropertiesType | Description |
---|---|
Color | Additive color to apply when rendered |
- Overrides
- Source
angle
PropertiesType | Description |
---|---|
Number | Angle to rotate the object |
- Overrides
- Source
angleDamping
PropertiesName | Type | Attributes | Default | Description |
---|---|---|---|---|
angleDamping | Number | <optional> | objectDefaultAngleDamping | How much to slow down rotation each frame (0-1) |
- Overrides
- Source
angleVelocity
PropertiesType | Description |
---|---|
Number | Angular velocity of the object |
- Overrides
- Source
children
PropertiesType | Description |
---|---|
Array | List of children of this object |
- Overrides
- Source
clampSpeedLinear
PropertiesType | Description |
---|---|
Boolean | Limit object speed using linear or circular math |
- Overrides
- Source
collideRaycast
PropertiesType | Description |
---|---|
Boolean | Object collides with raycasts |
- Overrides
- Source
collideSolidObjects
PropertiesType | Description |
---|---|
Boolean | Object collides with solid objects |
- Overrides
- Source
collideTiles
PropertiesType | Description |
---|---|
Boolean | Object collides with the tile collision |
- Overrides
- Source
color
PropertiesType | Description |
---|---|
Color | Color to apply when rendered |
- Overrides
- Source
colorEndDelta
PropertiesType | Description |
---|---|
Color | Calculated change in color |
- Source
colorStart
PropertiesType | Description |
---|---|
Color | Color at start of life |
- Source
damping
PropertiesName | Type | Attributes | Default | Description |
---|---|---|---|---|
damping | Number | <optional> | objectDefaultDamping | How much to slow down velocity each frame (0-1) |
- Overrides
- Source
destroyCallback
PropertiesType | Description |
---|---|
function | Called when particle dies |
- Source
drawSize
PropertiesType | Description |
---|---|
Vector2 | Size of object used for drawing, uses size if not set |
- Overrides
- Source
elasticity
PropertiesName | Type | Attributes | Default | Description |
---|---|---|---|---|
elasticity | Number | <optional> | objectDefaultElasticity | How bouncy the object is when colliding (0-1) |
- Overrides
- Source
fadeRate
PropertiesType | Description |
---|---|
Number | How quick to fade in/out |
- Source
friction
PropertiesName | Type | Attributes | Default | Description |
---|---|---|---|---|
friction | Number | <optional> | objectDefaultFriction | How much friction to apply when sliding (0-1) |
- Overrides
- Source
gravityScale
PropertiesType | Description |
---|---|
Number | How much to scale gravity by for this object |
- Overrides
- Source
isSolid
PropertiesType | Description |
---|---|
Boolean | Object collides with and blocks other objects |
- Overrides
- Source
lifeTime
PropertiesType | Description |
---|---|
Number | How long to live for |
- Source
localAngle
PropertiesType | Description |
---|---|
Number | Local angle if child |
- Overrides
- Source
localPos
PropertiesType | Description |
---|---|
Vector2 | Local position if child |
- Overrides
- Source
localSpaceEmitter
PropertiesType | Description |
---|---|
ParticleEmitter | Parent emitter if local space |
- Source
mass
PropertiesName | Type | Attributes | Default | Description |
---|---|---|---|---|
mass | Number | <optional> | objectDefaultMass | How heavy the object is, static if 0 |
- Overrides
- Source
mirror
PropertiesType | Description |
---|---|
Boolean | Should it flip along y axis when rendered |
- Overrides
- Source
parent
PropertiesType | Description |
---|---|
EngineObject | Parent of object if in local space |
- Overrides
- Source
pos
PropertiesType | Description |
---|---|
Vector2 | World space position of the object |
- Overrides
- Source
renderOrder
PropertiesType | Description |
---|---|
Number | Objects are sorted by render order |
- Overrides
- Source
size
PropertiesType | Description |
---|---|
Vector2 | World space width and height of the object |
- Overrides
- Source
sizeEndDelta
PropertiesType | Description |
---|---|
Number | Calculated change in size |
- Source
sizeStart
PropertiesType | Description |
---|---|
Number | Size at start of life |
- Source
spawnTime
PropertiesType | Description |
---|---|
Number | Track when object was created |
- Overrides
- Source
tileInfo
PropertiesType | Description |
---|---|
TileInfo | Tile info to render object (undefined is untextured) |
- Overrides
- Source
trailScale
PropertiesType | Description |
---|---|
Number | If a trail, how long to make it |
- Source
velocity
PropertiesType | Description |
---|---|
Vector2 | Velocity of the object |
- Overrides
- Source
Methods
addChild(child, localPosopt, localAngleopt)
Attaches a child to this with a given local transform
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
child | EngineObject | |||
localPos | Vector2 | <optional> | (0,0) | |
localAngle | Number | <optional> | 0 |
- Overrides
- Source
applyAcceleration(acceleration)
Apply acceleration to this object (adjust velocity, not affected by mass)
Name | Type | Description |
---|---|---|
acceleration | Vector2 |
- Overrides
- Source
applyForce(force)
Apply force to this object (adjust velocity, affected by mass)
Name | Type | Description |
---|---|---|
force | Vector2 |
- Overrides
- Source
collideWithObject(object) → {Boolean}
Called to check if a object collision should be resolved
Name | Type | Description |
---|---|---|
object | EngineObject | the object to test against |
- Overrides
- Source
- true if the collision should be resolved
- Type:
- Boolean
collideWithTile(tileData, pos) → {Boolean}
Called to check if a tile collision should be resolved
Name | Type | Description |
---|---|---|
tileData | Number | the value of the tile at the position |
pos | Vector2 | tile where the collision occured |
- Overrides
- Source
- 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
- Overrides
- Source
getAliveTime() → {Number}
How long since the object was created
- Overrides
- Source
- Type:
- Number
getMirrorSign() → {Number}
Get the direction of the mirror
- Overrides
- Source
-1 if this.mirror is true, or 1 if not mirrored
- Type:
- Number
localToWorld(pos)
Convert from local space to world space
Name | Type | Description |
---|---|---|
pos | Vector2 | local space point |
- Overrides
- Source
localToWorldVector(vec)
Convert from local space to world space for a vector (rotation only)
Name | Type | Description |
---|---|---|
vec | Vector2 | local space vector |
- Overrides
- Source
removeChild(child)
Removes a child from this one
Name | Type | Description |
---|---|---|
child | EngineObject |
- Overrides
- Source
render()
Render the particle, automatically called each frame, sorted by renderOrder
- Overrides
- Source
renderDebugInfo()
Render debug info for this object
- Overrides
- Source
setCollision(collideSolidObjectsopt, isSolidopt, collideTilesopt, collideRaycastopt)
Set how this object collides
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
collideSolidObjects | Boolean | <optional> | true | Does it collide with solid objects? |
isSolid | Boolean | <optional> | true | Does it collide with and block other objects? (expensive in large numbers) |
collideTiles | Boolean | <optional> | true | Does it collide with the tile collision? |
collideRaycast | Boolean | <optional> | true | Does it collide with raycasts? |
- Overrides
- Source
toString() → {String}
Returns string containg info about this object for debugging
- Overrides
- Source
- Type:
- String
update()
Update the object physics, called automatically by engine once each frame
- Overrides
- Source
updateTransforms()
Update the object transform, called automatically by engine even when paused
- Overrides
- Source
worldToLocal(pos)
Convert from world space to local space
Name | Type | Description |
---|---|---|
pos | Vector2 | world space point |
- Overrides
- Source
worldToLocalVector(vec)
Convert from world space to local space for a vector (rotation only)
Name | Type | Description |
---|---|---|
vec | Vector2 | world space vector |
- Overrides
- Source