Class: PIXI.CanvasRenderer
Constructor
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 | PhaserGame | A reference to the Phaser Game instance |
- Source code: pixi/renderers/canvas/CanvasRenderer.js (Line 5)
Public Properties
- Source code: pixi/renderers/canvas/CanvasRenderer.js (Line 61)
- Source code: pixi/renderers/canvas/CanvasRenderer.js (Line 118)
- Source code: pixi/renderers/canvas/CanvasRenderer.js (Line 41)
- Source code: pixi/renderers/canvas/CanvasRenderer.js (Line 95)
- Source code: pixi/renderers/canvas/CanvasRenderer.js (Line 110)
- Source code: pixi/renderers/canvas/CanvasRenderer.js (Line 15)
- Default Value
- 600
- Source code: pixi/renderers/canvas/CanvasRenderer.js (Line 78)
- Source code: pixi/renderers/canvas/CanvasRenderer.js (Line 102)
- Source code: pixi/renderers/canvas/CanvasRenderer.js (Line 125)
- Source code: pixi/renderers/canvas/CanvasRenderer.js (Line 33)
- Source code: pixi/renderers/canvas/CanvasRenderer.js (Line 53)
- Source code: pixi/renderers/canvas/CanvasRenderer.js (Line 25)
- Source code: pixi/renderers/canvas/CanvasRenderer.js (Line 87)
- Default Value
- 800
- Source code: pixi/renderers/canvas/CanvasRenderer.js (Line 69)
autoResize : boolean
Whether the render view should be resized automatically
CanvasMaskManager : PIXI.CanvasMaskManager
Instance of a PIXI.CanvasMaskManager, handles masking when using the canvas renderer
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.
context :CanvasRenderingContext2D
The canvas 2d context that everything is drawn with
count : number
Internal var.
game :PhaserGame
height : number
The height of the canvas view
refresh : boolean
Boolean flag controlling canvas refresh.
renderSession : Object
The render session is just a bunch of parameter used for rendering
resolution : number
The resolution of the canvas.
transparent : boolean
Whether the render view is transparent
type : number
The renderer type.
view :HTMLCanvasElement
The canvas element that everything is drawn to.
width : number
The width of the canvas view
Public Methods
- Source code: pixi/renderers/canvas/CanvasRenderer.js (Line 194)
- Source code: pixi/renderers/canvas/CanvasRenderer.js (Line 152)
- Source code: pixi/renderers/canvas/CanvasRenderer.js (Line 216)
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. |
render(root)
Renders the DisplayObjectContainer, usually the Phaser.Stage, to this canvas view.
Parameters
Name | Type | Description |
---|---|---|
root | PhaserStage | PIXIDisplayObjectContainer | The root element to be rendered. |
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 |
© 2016 Richard Davey, Photon Storm Ltd.
Licensed under the MIT License.
http://phaser.io/docs/2.6.2/PIXI.CanvasRenderer.html