Class: Renderer

Renderer

new Renderer(gamestage)

Renderer handles rendering a map file to the canvas
Parameters:
Name Type Description
gamestage stage EaselJS stage
Source:

Methods

beginCaching(container)

Forces caching on a container, caching the entire map size. disallows in animations in map
Parameters:
Name Type Description
container Container
Source:

centerMapOnObject(centeredObject, centeringCallback)

Tells the renderer to attempt to center on an object
Parameters:
Name Type Description
centeredObject Object
centeringCallback callback
Source:

centerMapOnObjectTick() → {boolean}

centerMapOnObjectTick attempts to center the map on an object. returns true once the map is either centered or the map has reached an edge when trying to center
Source:
Returns:
true if centered false if not
Type
boolean

getCanvasHeight() → {number}

Gets the canvas height in pixels
Source:
Returns:
Type
number

getCanvasWidth() → {number}

Gets the canvas width in pixels
Source:
Returns:
Type
number

getMapHeight() → {number}

Returns map width
Source:
Returns:
Type
number

getMapWidth() → {number}

Returns map width
Source:
Returns:
Type
number

initMap()

Initializes the renderer, gets it ready to render a new map
Source:

movementTickActions()

Function to handle moving objects from startxy to movingToCellTarget
Source:

moveObjectTo(trackedObject, targetx, targety) → {boolean}

Shifts the map in a certain way
Parameters:
Name Type Description
trackedObject Object
targetx number
targety number
Source:
Returns:
Type
boolean

prepareRenderer(mapData)

Reinitialize all of our variables here, gets us ready to draw a new map
Parameters:
Name Type Description
mapData Object new map JSON
Source:

setImage(image)

Sets renderer's imageData
Parameters:
Name Type Description
image Image
Source:

(inner) canShiftMapDown(speed) → {boolean}

Returns true if the map can shift down, false if not
Parameters:
Name Type Description
speed number
Source:
Returns:
Type
boolean

(inner) canShiftMapLeft(speed) → {boolean}

Returns true if the map can shift left, false if not
Parameters:
Name Type Description
speed number
Source:
Returns:
Type
boolean

(inner) canShiftMapRight(speed) → {number}

Returns true if the map can shift right, false if not
Parameters:
Name Type Description
speed number
Source:
Returns:
Type
number

(inner) canShiftMapUp(speed) → {boolean}

Returns true if the map can shift up, false if not
Parameters:
Name Type Description
speed number
Source:
Returns:
Type
boolean

(inner) distanceFromCenteredX(obj) → {number}

Returns distance from the center of the screen positive means needs containers need to shift right by half returned number of pixels to be centered positive means needs object need to shift left by half returned number of pixels to be centered
Parameters:
Name Type Description
obj Object
Source:
Returns:
Type
number

(inner) distanceFromCenteredY(obj) → {number}

Returns distance from the center of the screen positive means containers needs to go up by half returned number of pixels to be centered positive means object needs to go down by half returned number of pixels to be centered
Parameters:
Name Type Description
obj Object
Source:
Returns:
Type
number

(inner) tryCentering(obj, speed) → {boolean}

Attempts to center the screen, should get closer every frame
Parameters:
Name Type Description
obj Object
speed number
Source:
Returns:
false if the screen can't get more centered
Type
boolean