Constructor
new Spritesheet(options)
Creates a new Spritesheet
Name | Type | Description |
---|---|---|
options | Object | Spritesheet options |
- Source
// Includes all Spritesheet options
new Spritesheet({
container: game.Render.app.stage, // PIXI Container
layer: 0,
position: new vec(0, 0),
angle: 0,
visible: true,
alpha: 1,
speed: 1 / 6,
src: "",
animation: "",
scale: new vec(1, 1),
width: undefined, // Number | undefined
height: undefined, // Number | undefined
});
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()
Adds the sprite to the world
- Overrides
- Source
delete()
Removes the sprite from the world
- Overrides
- Source
setSpeed(speed)
Sets the animation's speed
Name | Type | Description |
---|---|---|
speed | Number |
- Source
setLayer(layer)
Sets the render layer (z index)
Name | Type | Description |
---|---|---|
layer | number | Render layer (z index) for the render |
- Source
setScale(scale)
Sets the sprite's scale
Name | Type | Description |
---|---|---|
scale | vec | New scale |
- Source
setSize(width, height)
Sets the sprite's width and height
Name | Type | Description |
---|---|---|
width | number | New width |
height | number | New height |
- Source
setAlpha(alpha)
Sets the sprite's alpha
Name | Type | Description |
---|---|---|
alpha | number | Opacity, between 0 and 1 inclusive |
- Source
setVisible(visible)
Changes if the sprite is visible
Name | Type | Description |
---|---|---|
visible | boolean | If the sprite is visible |
- Source
translate(delta)
Shifts the sprite's position by delta
Name | Type | Description |
---|---|---|
delta | vec | Amount sprite is shifted by |
- Overrides
- Source
translateAngle(angle)
Rotates the sprite relative to current angle
Name | Type | Description |
---|---|---|
angle | number | Amount to rotate sprite, in radians |
- Overrides
- Source
destroy()
Destroys the sprite. Use when you know the sprite 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