Canvas

Canvas

new Canvas(widthopt, heightopt, optionsopt)

Use of `createCanvas` preferred.
Source:
Parameters:
Name Type Attributes Description
width Number <optional>
height Number <optional>
options Object <optional>
canvas options or renderer
Returns:
HTML5 canvas element

Classes

Canvas

Methods

resize(w, h)

Resizes the canvas, the world, and centers the camera. Visually the canvas will shrink or extend to the new size. Sprites will not change position. If you would prefer to keep the camera focused on the same area, then you must manually adjust the camera position after calling this function.
Source:
Parameters:
Name Type Description
w Number the new width of the canvas
h Number the new height of the canvas

save(file)

Saves the current canvas as an image file.
Source:
Parameters:
Name Type Description
file String the name of the image