Constructor
new PolygonRender(options) → {PolygonRender}
Creates a PolygonRender for rendering rigid bodies
Name | Type | Description |
---|---|---|
options | Object |
- Source
this
- Type:
- PolygonRender
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
setLayer(layer)
Sets the render layer (z index)
Name | Type | Description |
---|---|---|
layer | number | Render layer (z index) for the render |
- Source
setAlpha(alpha)
Sets the render's alpha
Name | Type | Description |
---|---|---|
alpha | number | Opacity, between 0 and 1 inclusive |
- Source
setVisible(visible)
Changes if the render is visible
Name | Type | Description |
---|---|---|
visible | boolean | If the render is visible |
- Source
translate(delta)
Shifts the render's position by delta
Name | Type | Description |
---|---|---|
delta | vec | Position render is shifted |
- Overrides
- Source
translateAngle(angle)
Rotates the render relative to current angle
Name | Type | Description |
---|---|---|
angle | number | Amount to rotate render, in radians |
- Overrides
- Source
add()
Adds the render object to the world
- Overrides
- Source
delete()
Removes the render object from the world
- Overrides
- Source
destroy()
Destroys the render object. Use when you know the render will no longer be used
- Source
on(event, callback)
Binds a function to an event
Name | Type | Description |
---|---|---|
event | "load" | | Name of the event |
callback | function | Function called when event fires |
- Overrides
- Source
off(event, callback)
Unbinds a function from an event
Name | Type | Description |
---|---|---|
event | "load" | | Name of the event |
callback | function | Function bound to event |
- Overrides
- Source
trigger(event)
Fires an event
Name | Type | Description |
---|---|---|
event | "load" | | Name of the event |
- Overrides
- Source
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)
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