Class: CanvasRenderer

PIXI. CanvasRenderer

new CanvasRenderer(game)

The CanvasRenderer draws the Stage and all its content onto a 2d canvas. This renderer should be used for browsers that do not support webGL. Don't forget to add the CanvasRenderer.view to your DOM or you will not see anything :)

Parameters:
Name Type Description
game Phaser.Game

A reference to the Phaser Game instance

Source:
src/pixi/renderers/canvas/CanvasRenderer.js line 13

Members

autoResize : Boolean

Whether the render view should be resized automatically

Type:
  • Boolean
Source:
src/pixi/renderers/canvas/CanvasRenderer.js line 62

clearBeforeRender : Boolean

This sets if the CanvasRenderer will clear the canvas or not before the new render pass. If the Stage is NOT transparent Pixi will use a canvas sized fillRect operation every frame to set the canvas background color. If the Stage is transparent Pixi will use clearRect to clear the canvas every frame. Disable this by setting this to false. For example if your game has a canvas filling background image you often don't need this set.

Type:
  • Boolean
Source:
src/pixi/renderers/canvas/CanvasRenderer.js line 46

context : CanvasRenderingContext2D

The canvas 2d context that everything is drawn with

Type:
  • CanvasRenderingContext2D
Source:
src/pixi/renderers/canvas/CanvasRenderer.js line 95

count : Number

Internal var.

Type:
  • Number
Source:
src/pixi/renderers/canvas/CanvasRenderer.js line 116

game : Phaser.Game

A reference to the Phaser Game instance.

Type:
Source:
src/pixi/renderers/canvas/CanvasRenderer.js line 18

height : Number

The height of the canvas view

Type:
  • Number
Default Value:
  • 600
Source:
src/pixi/renderers/canvas/CanvasRenderer.js line 80

maskManager : CanvasMaskManager

Instance of a PIXI.CanvasMaskManager, handles masking when using the canvas renderer

Type:
  • CanvasMaskManager
Properties:
Name Type Description
CanvasMaskManager
Source:
src/pixi/renderers/canvas/CanvasRenderer.js line 123

refresh : Boolean

Boolean flag controlling canvas refresh.

Type:
  • Boolean
Source:
src/pixi/renderers/canvas/CanvasRenderer.js line 108

renderSession : Object

The render session is just a bunch of parameter used for rendering

Type:
  • Object
Source:
src/pixi/renderers/canvas/CanvasRenderer.js line 130

resolution : Number

The resolution of the canvas.

Type:
  • Number
Source:
src/pixi/renderers/canvas/CanvasRenderer.js line 34

transparent : Boolean

Whether the render view is transparent

Type:
  • Boolean
Source:
src/pixi/renderers/canvas/CanvasRenderer.js line 54

type : Number

The renderer type.

Type:
  • Number
Source:
src/pixi/renderers/canvas/CanvasRenderer.js line 26

view : HTMLCanvasElement

The canvas element that everything is drawn to.

Type:
  • HTMLCanvasElement
Source:
src/pixi/renderers/canvas/CanvasRenderer.js line 88

width : Number

The width of the canvas view

Type:
  • Number
Default Value:
  • 800
Source:
src/pixi/renderers/canvas/CanvasRenderer.js line 71

Methods

destroy( [removeView])

Removes everything from the renderer and optionally removes the Canvas DOM element.

Parameters:
Name Type Argument Default Description
removeView boolean <optional>
true

Removes the Canvas element from the DOM.

Source:
src/pixi/renderers/canvas/CanvasRenderer.js line 207

render(root)

Renders the DisplayObjectContainer, usually the Phaser.Stage, to this canvas view.

Parameters:
Name Type Description
root Phaser.Stage | PIXI.DisplayObjectContainer

The root element to be rendered.

Source:
src/pixi/renderers/canvas/CanvasRenderer.js line 151

resize(width, height)

Resizes the canvas view to the specified width and height

Parameters:
Name Type Description
width Number

the new width of the canvas view

height Number

the new height of the canvas view

Source:
src/pixi/renderers/canvas/CanvasRenderer.js line 228

phaser-ce@2.20.1 is on GitHub and NPM

Documentation generated by JSDoc 3.6.11 on 2024-10-05 using Tomorrow.