Render

Main render object that handles the camera, pixel ratio, resizing, what is rendered, etc

Events

NameDescriptionArguments
beforeUpdateBefore the render scene is moved to match the camera position and scale. Triggered every frame.None
afterUpdateAfter the render scene is moved to match the camera position and scale. Triggered every frame.None

Constructor

new Render(options)

Parameters:
NameTypeDescription
optionsobject

Render options

Properties
NameTypeAttributesDefaultDescription
backgroundstring<optional>
"transparent"

Background color, such as "#FFFFFF00", "rgb(0, 0, 0)", or "transparent"

pixelRationumber<optional>
devicePixelRatio

Render resolution percent, use default unless you have a reason to change it

ySortboolean<optional>
false

Whether to sort the render layer of bodies by their y coordinate

parentElement*<optional>
window

What the canvas element will be appended to. The canvas resizes to fit this element. Only set to window if the body has overflow: hidden, otherwise create a wrapper element.

antialiasboolean<optional>
true

If the render should have antialiasing

scaleModeboolean<optional>
PIXI.SCALE_MODES.LINEAR

See PIXI.js scale modes

getBoundSizefunction<optional>
function(width, height)

Function that determines the bound size, which is how big the view should be based on the canvas width and height

Methods

update(delta)

Updates renderer and its camera. Triggers beforeUpdate and afterUpdate events on this Render.

Parameters:
NameTypeDescription
deltanumber

Frame time, in seconds