Constructor
# new EngineObject(positionopt, sizeopt, tileIndexopt, tileSizeopt, angleopt, coloropt)
Create an engine object and adds it to the list of objects
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
position |
Vector2 |
<optional> |
new Vector2(0,0) | World space position of the object |
size |
Vector2 |
<optional> |
defaultObjectSize | World space size of the object |
tileIndex |
Number |
<optional> |
-1 | Tile to use to render object, untextured if -1 |
tileSize |
Vector2 |
<optional> |
defaultTileSize | Size of tile in source pixels |
angle |
Number |
<optional> |
0 | Angle to rotate the object |
color |
Color |
<optional> |
Color to apply to tile when rendered |
- Source:
Methods
# addChild(child, localPosopt, localAngleopt)
Attaches a child to this with a given local transform
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
child |
EngineObject | |||
localPos |
Vector2 |
<optional> |
new Vector2 | |
localAngle |
Number |
<optional> |
0 |
- Source:
# applyAcceleration(acceleration)
Apply acceleration to this object (adjust velocity, not affected by mass)
Parameters:
Name | Type | Description |
---|---|---|
acceleration |
Vector2 |
- Source:
# applyForce(force)
Apply force to this object (adjust velocity, affected by mass)
Parameters:
Name | Type | Description |
---|---|---|
force |
Vector2 |
- Source:
# collideWithObject(object) → {Boolean}
Called to check if a tile raycast hit
Parameters:
Name | Type | Description |
---|---|---|
object |
EngineObject | the object to test against |
- Source:
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:
Name | Type | Description |
---|---|---|
tileData |
Number | the value of the tile at the position |
pos |
Vector2 | tile where the collision occured |
- Source:
Returns:
true if the collision should be resolved
- Type
- Boolean
# collideWithTileRaycast(tileData, pos) → {Boolean}
Called to check if a tile raycast hit
Parameters:
Name | Type | Description |
---|---|---|
tileData |
Number | the value of the tile at the position |
pos |
Vector2 | tile where the raycast is |
- Source:
Returns:
true if the raycast should hit
- Type
- Boolean
# destroy()
Destroy this object, destroy it's children, detach it's parent, and mark it for removal
- Source:
# getAliveTime() → {Number}
How long since the object was created
- Source:
Returns:
- Type
- Number
# getMirrorSign() → {Number}
Get the direction of the mirror
- Source:
Returns:
-1 if this.mirror is true, or 1 if not mirrored
- Type
- Number
# removeChild(child)
Removes a child from this one
Parameters:
Name | Type | Description |
---|---|---|
child |
EngineObject |
- Source:
# render()
Render the object, draws a tile by default, automatically called each frame, sorted by renderOrder
- Source:
# setCollision(collideSolidObjectsopt, isSolidopt, collideTilesopt)
Set how this object collides
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
collideSolidObjects |
boolean |
<optional> |
0 | Does it collide with solid objects |
isSolid |
boolean |
<optional> |
0 | Does it collide with and block other objects (expensive in large numbers) |
collideTiles |
boolean |
<optional> |
1 | Does it collide with the tile collision |
- Source:
# update()
Update the object transform and physics, called automatically by engine once each frame
- Source: