Class: Entity

Entity(options)

Entity is the base class for subgraphics.

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)
Source:

(static, constant) STOPSTATUS_REPLACED

The animation was stopped because animateStart was called with a new animation, replacing it
Source:

(static, constant) STOPSTATUS_STOPPED

The animation was stopped with animateStop
Source:

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 ]:
Source:

animateStart(animation)

Start an animation
Parameters:
Name Type Description
animation Object An animation definition:
Properties
Name Type Description
name String The name of the animation to start, must have been previously defined by addAnimation
delay Integer Default delay for each frame (unless overridden by the dt in the frame)
frame Integer The index of the starting frame (optional, defaults to 0)
loop Boolean Loop the animation (i) indefinitely if 'true' (ii) this number of times. (optional)
dx Integer x Delta at every frame (move x pixels), unless overridden by the dx in the frame (optional)
dy Integer y Delta at every frame (move y pixels), unless overridden by the dy in the frame (optional)
minX Integer Stop the animation when the x is equal or less than this value (optional)
minY Integer Stop the animation when the y is equal or less than this value (optional)
maxX Integer Stop the animation when the x is equal or greater than this value (optional)
maxY Integer Stop the animation when the y is equal or greater than this value (optional)
stopTile Tile Set this tile [x,y] when the animation stops (optional)
onStop function A function to call when the animation stops, fn(entity) where entity is this entity (optional)
Source:

animateStop(stopStatus)

Stop the current animation with an optional Stop Status
Parameters:
Name Type Description
stopStatus Integer The stop status
Source:

draw(context)

Draw the Entity into the given context.
Parameters:
Name Type Description
context CanvasRenderingContext2D The context in which to draw
Source:

redraw()

Mark the entity to be redrawn
Source: