Class: AnimatedEntity

Splat. AnimatedEntity

new AnimatedEntity(x, y, width, height, sprite, spriteOffsetX, spriteOffsetY)

An upgraded Splat.Entity that knows how to draw and advance an Animation.
Parameters:
Name Type Description
x number The top-left x coordinate. See Splat.Entity#x
y number The top-left y coordinate. See Splat.Entity#y
width number The width on the x-axis. See Splat.Entity#width
height number The height on the y-axis. See Splat.Entity#height
sprite Animation | external:image The Animation or image to draw
spriteOffsetX number How much to offset Splat.AnimatedEntity#sprite from the Splat.Entity#x when drawing
spriteOffsetY number How much to offset Splat.AnimatedEntity#sprite from the Splat.Entity#y when drawing
Source:

Extends

Members

height :number

Height of the Entity, extending downward from Splat.Entity#y.
Type:
  • number
Inherited From:
Source:

(readonly) lastX :number

The value of Splat.Entity#x in the previous frame.
Type:
  • number
Inherited From:
Source:

(readonly) lastY :number

The value of Splat.Entity#y in the previous frame.
Type:
  • number
Inherited From:
Source:

sprite :Animation|external:image

The Animation or image to draw
Type:
Source:

spriteOffsetX :number

How much to offset Splat.AnimatedEntity#sprite from Splat.Entity#x when drawing.
Type:
  • number
Source:

spriteOffsetY :number

How much to offset Splat.AnimatedEntity#sprite from Splat.Entity#y when drawing.
Type:
  • number
Source:

vx :number

Velocity along the x-axis in pixels/millisecond.
Type:
  • number
Inherited From:
Source:

vy :number

Velocity along the y-axis in pixels/millisecond.
Type:
  • number
Inherited From:
Source:

width :number

Width of the Entity, extending to the right of Splat.Entity#x.
Type:
  • number
Inherited From:
Source:

x :number

Leftmost position along the x-axis.
Type:
  • number
Inherited From:
Source:

y :number

Topmost position along the y-axis.
Type:
  • number
Inherited From:
Source:

Methods

collides(other) → {boolean}

Test if this Entity is currently colliding with another.
Parameters:
Name Type Description
other Splat.Entity The Entity to test for collision with
Inherited From:
Source:
Returns:
Type
boolean

copy() → {Splat.AnimatedEntity}

Make a copy of this AnimatedEntity. The Splat.AnimatedEntity#sprite is not copied, so both entities will share it.
Source:
Returns:
Type
Splat.AnimatedEntity

didOverlapHoriz(other) → {boolean}

Test if this Entity horizontally overlapped another in the previous frame.
Parameters:
Name Type Description
other Splat.Entity The Entity to test for overlap with
Inherited From:
Source:
Returns:
Type
boolean

didOverlapVert(other) → {boolean}

Test if this Entity vertically overlapped another in the previous frame.
Parameters:
Name Type Description
other Splat.Entity The Entity to test for overlap with
Inherited From:
Source:
Returns:
Type
boolean

draw(context)

Parameters:
Name Type Description
context external:CanvasRenderingContext2D The drawing context.
Source:

getCollisions(entities) → {Array}

Return a list of all Entities that collide with this Entity.
Parameters:
Name Type Description
entities Array A list of Entities to check for collisions.
Inherited From:
Source:
Returns:
A list of entities that collide with this Entity.
Type
Array

move(elapsedMillis)

Simulate movement since the last frame, changing Splat.Entity#x, Splat.Entity#y, and calling Animation#move if applicable.
Parameters:
Name Type Description
elapsedMillis number The number of milliseconds since the last frame.
Overrides:
Source:

moved() → {boolean}

Test if this Entity has changed position since the previous frame.
Inherited From:
Source:
Returns:
Type
boolean

overlapsHoriz(other) → {boolean}

Test if this Entity horizontally overlaps another.
Parameters:
Name Type Description
other Splat.Entity The Entity to test for overlap with
Inherited From:
Source:
Returns:
Type
boolean

overlapsVert(other) → {boolean}

Test if this Entity vertically overlaps another.
Parameters:
Name Type Description
other Splat.Entity The Entity to test for overlap with
Inherited From:
Source:
Returns:
Type
boolean

resolveBottomCollisionWith(other)

Adjust the Entity's position so its bottom edge does not penetrate the other Entity's top edge. Splat.Entity#vy is also zeroed.
Parameters:
Name Type Description
other Splat.Entity
Inherited From:
Source:

resolveCollisionWith(other)

Adjust the Entity's position so it does not penetrate the other Entity. Splat.Entity#vx will be zeroed if Splat.Entity#x was adjusted, and Splat.Entity#vy will be zeroed if Splat.Entity#y was adjusted.
Parameters:
Name Type Description
other Splat.Entity
Inherited From:
Source:

resolveLeftCollisionWith(other)

Adjust the Entity's position so its left edge does not penetrate the other Entity's right edge. Splat.Entity#vx is also zeroed.
Parameters:
Name Type Description
other Splat.Entity
Inherited From:
Source:

resolveRightCollisionWith(other)

Adjust the Entity's position so its right edge does not penetrate the other Entity's left edge. Splat.Entity#vx is also zeroed.
Parameters:
Name Type Description
other Splat.Entity
Inherited From:
Source:

resolveTopCollisionWith(other)

Adjust the Entity's position so its top edge does not penetrate the other Entity's bottom edge. Splat.Entity#vy is also zeroed.
Parameters:
Name Type Description
other Splat.Entity
Inherited From:
Source:

solveCollisions(entities) → {Array}

Detect and resolve collisions between this Entity and a list of other Entities
Parameters:
Name Type Description
entities Array A list of Entities to solve against.
Inherited From:
Source:
Returns:
A list of entities that were involved in collisions.
Type
Array

wasAbove(other) → {boolean}

Test if this Entity was above another in the previous frame.
Parameters:
Name Type Description
other Splat.Entity The Entity to test for above-ness with
Inherited From:
Source:
Returns:
Type
boolean

wasBelow(other) → {boolean}

Test if this Entity was below another in the previous frame.
Parameters:
Name Type Description
other Splat.Entity The Entity to test for below-ness with
Inherited From:
Source:
Returns:
Type
boolean

wasLeft(other) → {boolean}

Test if this Entity was to the left of another in the previous frame.
Parameters:
Name Type Description
other Splat.Entity The Entity to test for left-ness with
Inherited From:
Source:
Returns:
Type
boolean

wasRight(other) → {boolean}

Test if this Entity was to the right of another in the previous frame.
Parameters:
Name Type Description
other Splat.Entity The Entity to test for right-ness with
Inherited From:
Source:
Returns:
Type
boolean