Constructor
new World(options)
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options | object | World options Properties
|
- Source
Extends
Members
(readonly) nodeType
Type of node, ie Node
or RigidBody
- Overrides
- Source
(readonly) position :vec
Position of the node
- Overrides
- Source
- To Do
- Implement getPosition method and make this private
(readonly) angle :number
Angle, in radians
- number
- Overrides
- Source
- To Do
- Implement getAngle method and make this private
(readonly) children :Set
Children of the node To modify, use addChild
or removeChild
.
- Set
- Overrides
- Source
Methods
add() → {Node}
Adds this node and its children, triggering the add
event
- Overrides
- Source
this
- Type:
- Node
delete() → {Node}
Removes this node and its children, triggering the delete
event
- Overrides
- Source
this
- Type:
- Node
isAdded() → {Boolean}
Gets if the node is added
- Overrides
- Source
if the node is added
- Type:
- Boolean
addChild(…children)
Adds all children
to this node's children
Name | Type | Attributes | Description |
---|---|---|---|
children | Node | <repeatable> | Children added |
- Overrides
- Source
let parentNode = new Node();
let childNode = new Node();
node.addChild(childNode);
removeChild(…children)
Removes all children
from this node's children
Name | Type | Attributes | Description |
---|---|---|---|
children | Node | <repeatable> | Children removed |
- Overrides
- Source
let parentNode = new Node();
let childNode = new Node();
node.addChild(childNode); // node.children: Set {childNode}
node.removeChild(childNode); // node.children: Set {}
setPosition(position)
Sets this node's position to position
Name | Type | Description |
---|---|---|
position | vec | Position the node should be set to |
- Overrides
- Source
node.setPosition(new vec(100, 100)); // Sets node's position to (100, 100)
translate(positionDelta)
Shifts this node's position by positionDelta
Name | Type | Description |
---|---|---|
positionDelta | vec | Amount to shift the position |
- Overrides
- Source
setAngle(angle)
Sets the node's angle to angle
Name | Type | Description |
---|---|---|
angle | number | Angle body should be in radians |
- Overrides
- Source
node.setAngle(Math.PI); // Sets node's angle to Pi radians, or 180 degrees
translateAngle(angle)
Rotates the body by angle
- Relative
Name | Type | Description |
---|---|---|
angle | number | Amount the body should be rotated, in radians |
- Overrides
- Source
on(event, callback)
Bind a callback to an event
Name | Type | Description |
---|---|---|
event | string | Name of the event |
callback | function | Callback run when event is fired |
- Overrides
- Source
off(event, callback)
Unbinds a callback from an event
Name | Type | Description |
---|---|---|
event | string | Name of the event |
callback | function | Function to unbind |
- Overrides
- Source
trigger(event, …args)
Triggers an event, firing all bound callbacks
Name | Type | Attributes | Description |
---|---|---|---|
event | string | Name of the event | |
args | * | <repeatable> | Arguments passed to callbacks |
- Overrides
- Source