Class: Camera

Splat. Camera

new Camera(x, y, width, height)

A basic camera. It's really an Splat.Entity, so you can control it in the same way. By changing Splat.Entity#x and Splat.Entity#y you control what portion of the canvas is viewable. For example, if the Camera is at 50,50, and you draw a rectangle at 200,200, it will appear on the screen at 150,150.
Parameters:
Name Type Description
x number The top-left x coordinate
y number The top-left y coordinate
width number The width on the x-axis. Currently doesn't do anything.
height number The height on the y-axis. Currently doesn't do anything.
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:

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

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)

Offset all following draw operations on the canvas. This is automatically called for you by Splat.Scene.
Parameters:
Name Type Description
context external:CanvasRendingContext2D The context to offset
Source:

drawAbsolute(context, drawFunc)

Draw on the canvas at not-offset coordinates. For example, if the camera is at 50,50 and you draw a rectangle at 200,200 it will appear on the screen at 200,200.
Parameters:
Name Type Description
context external:CanvasRendingContext2D The context to offset
drawFunc drawCallback The callback the performs the non-offset drawing.
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 previous frame, changing Splat.Entity#x and Splat.Entity#y as necessary.
Parameters:
Name Type Description
elapsedMillis number The number of milliseconds since the previous frame.
Inherited From:
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