Constructor
new Entity(options)
Create a new Entity with the specified options
Parameters:
Name | Type | Description |
---|---|---|
options |
Object | The options for the Entity, composed of the properties. |
Properties:
Name | Type | Description |
---|---|---|
asset |
Asset | The Asset to use for the Entity tiles |
parent |
Object | The parent of this Entity |
x |
integer | The x-coordinate in pixels relative to its parent (optional, default 0) |
y |
integer | The y-coordinate in pixels relative to its parent (optional, default 0) |
z |
integer | The z-coordinate relative to its parent (optional, default 0) |
scale |
float | The current scale (zoom) where 1 = 100% (optional, default 1) |
rotate |
float | The current rotation where 0ยบ (optional, default 0) |
visible |
boolean | Set if this Entity is visible (optional, default true) |
- Mixes In:
- Source:
Members
(static, constant) STOPSTATUS_COMPLETED
The animation stopped because it was finished (non-looped) or a boundary condition was met (maxX, maxY)
(static, constant) STOPSTATUS_REPLACED
The animation was stopped because animateStart was called with a new animation, replacing it
(static, constant) STOPSTATUS_STOPPED
The animation was stopped with animateStop
Methods
addAnimation(name, def)
Add an animation with the specified name and definition (def)
Parameters:
Name | Type | Description |
---|---|---|
name |
String | The name of the animation |
def |
Array.<Frame> | An array of Frames, Frame format is an array: [ tx, ty, dt, dx, dy ]: |
animateStart(animation)
Start an animation
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
animation |
Object | An animation definition:
Properties
|
animateStop(stopStatus)
Stop the current animation with an optional Stop Status
Parameters:
Name | Type | Description |
---|---|---|
stopStatus |
Integer | The stop status |
draw(context)
Draw the Entity into the given context.
Parameters:
Name | Type | Description |
---|---|---|
context |
CanvasRenderingContext2D | The context in which to draw |
redraw()
Mark the entity to be redrawn