Class: CanvasRenderer

Phaser.Renderer.Canvas. CanvasRenderer

[description]


new CanvasRenderer(game)

Parameters:
Name Type Description
game Phaser.Game

The Phaser Game instance that owns this renderer.

Since: 3.0.0
Source: src/renderer/canvas/CanvasRenderer.js (Line 16)

Members


blendModes :array

[description]

Type:
  • array
Since: 3.0.0
Source: src/renderer/canvas/CanvasRenderer.js (Line 131)

config :RendererConfig

[description]

Type:
Since: 3.0.0
Source: src/renderer/canvas/CanvasRenderer.js (Line 79)

currentContext :CanvasRenderingContext2D

[description]

Type:
  • CanvasRenderingContext2D
Since: 3.0.0
Source: src/renderer/canvas/CanvasRenderer.js (Line 122)

currentScaleMode :number

[description]

Type:
  • number
Since: 3.0.0
Default Value:
  • 0
Source: src/renderer/canvas/CanvasRenderer.js (Line 143)

drawCount :number

[description]

Type:
  • number
Since: 3.0.0
Default Value:
  • 0
Source: src/renderer/canvas/CanvasRenderer.js (Line 51)

game :Phaser.Game

The Phaser Game instance that owns this renderer.

Type:
Since: 3.0.0
Source: src/renderer/canvas/CanvasRenderer.js (Line 33)

gameCanvas :HTMLCanvasElement

[description]

Type:
  • HTMLCanvasElement
Since: 3.0.0
Source: src/renderer/canvas/CanvasRenderer.js (Line 104)

gameContext :CanvasRenderingContext2D

[description]

Type:
  • CanvasRenderingContext2D
Since: 3.0.0
Source: src/renderer/canvas/CanvasRenderer.js (Line 113)

height :number

[description]

Type:
  • number
Since: 3.0.0
Source: src/renderer/canvas/CanvasRenderer.js (Line 70)

scaleMode :integer

[description]

Type:
  • integer
Since: 3.0.0
Source: src/renderer/canvas/CanvasRenderer.js (Line 95)

<nullable> snapshotCallback :SnapshotCallback

[description]

Type:
Since: 3.0.0
Default Value:
  • null
Source: src/renderer/canvas/CanvasRenderer.js (Line 153)

<nullable> snapshotEncoder :number

[description]

Type:
  • number
Since: 3.0.0
Default Value:
  • null
Source: src/renderer/canvas/CanvasRenderer.js (Line 173)

<nullable> snapshotType :string

[description]

Type:
  • string
Since: 3.0.0
Default Value:
  • null
Source: src/renderer/canvas/CanvasRenderer.js (Line 163)

type :integer

[description]

Type:
  • integer
Since: 3.0.0
Source: src/renderer/canvas/CanvasRenderer.js (Line 42)

width :number

[description]

Type:
  • number
Since: 3.0.0
Source: src/renderer/canvas/CanvasRenderer.js (Line 61)

Methods


batchSprite(sprite, frame, camera [, parentTransformMatrix])

Takes a Sprite Game Object, or any object that extends it, and draws it to the current context.

Parameters:
Name Type Argument Description
sprite Phaser.GameObjects.GameObject

The texture based Game Object to draw.

frame Phaser.Textures.Frame

The frame to draw, doesn't have to be that owned by the Game Object.

camera Phaser.Cameras.Scene2D.Camera

The Camera to use for the rendering transform.

parentTransformMatrix Phaser.GameObjects.Components.TransformMatrix <optional>

The transform matrix of the parent container, if set.

Since: 3.12.0
Source: src/renderer/canvas/CanvasRenderer.js (Line 521)

destroy()

[description]

Since: 3.0.0
Source: src/renderer/canvas/CanvasRenderer.js (Line 645)

init()

[description]

Since: 3.0.0
Source: src/renderer/canvas/CanvasRenderer.js (Line 226)

onContextLost(callback)

[description]

Parameters:
Name Type Description
callback function

[description]

Since: 3.0.0
Source: src/renderer/canvas/CanvasRenderer.js (Line 269)

onContextRestored(callback)

[description]

Parameters:
Name Type Description
callback function

[description]

Since: 3.0.0
Source: src/renderer/canvas/CanvasRenderer.js (Line 281)

postRender()

[description]

Since: 3.0.0
Source: src/renderer/canvas/CanvasRenderer.js (Line 484)

preRender()

Called at the start of the render loop.

Since: 3.0.0
Source: src/renderer/canvas/CanvasRenderer.js (Line 355)

render(scene, children, interpolationPercentage, camera)

Renders the Scene to the given Camera.

Parameters:
Name Type Description
scene Phaser.Scene

[description]

children Phaser.GameObjects.DisplayList

[description]

interpolationPercentage number

[description]

camera Phaser.Cameras.Scene2D.Camera

[description]

Since: 3.0.0
Source: src/renderer/canvas/CanvasRenderer.js (Line 383)

resetTransform()

[description]

Since: 3.0.0
Source: src/renderer/canvas/CanvasRenderer.js (Line 293)

resize(width, height)

Resize the main game canvas.

Parameters:
Name Type Description
width integer

[description]

height integer

[description]

Since: 3.0.0
Source: src/renderer/canvas/CanvasRenderer.js (Line 237)

setAlpha(alpha)

[description]

Parameters:
Name Type Description
alpha number

[description]

Since: 3.0.0
Source: src/renderer/canvas/CanvasRenderer.js (Line 338)
Returns:

[description]

Type
Phaser.Renderer.Canvas.CanvasRenderer

setBlendMode(blendMode)

[description]

Parameters:
Name Type Description
blendMode number

[description]

Since: 3.0.0
Source: src/renderer/canvas/CanvasRenderer.js (Line 304)
Returns:

[description]

Type
Phaser.Renderer.Canvas.CanvasRenderer

setContext( [ctx])

Changes the Canvas Rendering Context that all draw operations are performed against.

Parameters:
Name Type Argument Description
ctx CanvasRenderingContext2D <optional>
<nullable>

The new Canvas Rendering Context to draw everything to. Leave empty to reset to the Game Canvas.

Since: 3.12.0
Source: src/renderer/canvas/CanvasRenderer.js (Line 321)
Returns:

The Canvas Renderer instance.

Type
Phaser.Renderer.Canvas.CanvasRenderer

snapshot(callback, type, encoderOptions)

[description]

Parameters:
Name Type Description
callback SnapshotCallback

[description]

type string

[description]

encoderOptions number

[description]

Since: 3.0.0
Source: src/renderer/canvas/CanvasRenderer.js (Line 504)