Phaser API Documentation

  Version: 
Filter
Namespace: Events
Phaser.Renderer.Events

Events

LOSE_WEBGL
Focus
Focus

Description:

The Lose WebGL Event.

This event is dispatched by the WebGLRenderer when the WebGL context is lost.

Context can be lost for a variety of reasons, like leaving the browser tab. The game canvas DOM object will dispatch webglcontextlost. All WebGL resources get wiped, and the context is reset.

While WebGL is lost, the game will continue to run, but all WebGL resources are lost, and new ones cannot be created.

Once the context is restored and the renderer has automatically restored the state, the renderer will emit a RESTORE_WEBGL event. At that point, it is safe to continue.

Parameters:

name type description
renderer Phaser.Renderer.WebGL.WebGLRenderer

the renderer that owns the WebGL context

Since: 3.80.0
Focus
Focus
POST_RENDER
Focus
Focus

Description:

The Post-Render Event.

This event is dispatched by the Renderer when all rendering, for all cameras in all Scenes, has completed, but before any pending snap shots have been taken.

Since: 3.50.0
Focus
Focus
PRE_RENDER
Focus
Focus

Description:

The Pre-Render Event.

This event is dispatched by the Phaser Renderer. This happens right at the start of the render process, after the context has been cleared, the scissors enabled (WebGL only) and everything has been reset ready for the render.

Since: 3.50.0
Focus
Focus
PRE_RENDER_CLEAR
Focus
Focus

Description:

The Pre-Render Clear Event.

This event is dispatched by the Phaser Renderer. It happens at the start of the render step, before the WebGL gl.clear function has been called. This allows you to toggle the config.clearBeforeRender property as required, to have fine-grained control over when the canvas is cleared during rendering.

Listen to it from within a Scene using: this.renderer.events.on('prerenderclear', listener).

It's very important to understand that this event is called before the scissor and mask stacks are cleared. This means you should not use this event to modify the scissor or mask. Instead, use the prerender event for that.

If using the Canvas Renderer, this event is dispatched before the canvas is cleared, but after the context globalAlpha and transform have been reset.

Since: 3.85.0
Focus
Focus
RENDER
Focus
Focus

Description:

The Render Event.

This event is dispatched by the Phaser Renderer for every camera in every Scene.

It is dispatched before any of the children in the Scene have been rendered.

Parameters:

name type description
scene Phaser.Scene

The Scene being rendered.

camera Phaser.Cameras.Scene2D.Camera

The Scene Camera being rendered.

Since: 3.50.0
Focus
Focus
RESIZE
Focus
Focus

Description:

The Renderer Resize Event.

This event is dispatched by the Phaser Renderer when it is resized, usually as a result of the Scale Manager resizing.

Parameters:

name type description
width number

The new width of the renderer.

height number

The new height of the renderer.

Since: 3.50.0
Focus
Focus
RESTORE_WEBGL
Focus
Focus

Description:

The Restore WebGL Event.

This event is dispatched by the WebGLRenderer when the WebGL context is restored.

It is dispatched after all WebGL resources have been recreated. Most resources should come back automatically, but you will need to redraw dynamic textures that were GPU bound. Listen to this event to know when you can safely do that.

Context can be lost for a variety of reasons, like leaving the browser tab. The game canvas DOM object will dispatch webglcontextlost. All WebGL resources get wiped, and the context is reset.

Once the context is restored, the canvas will dispatch webglcontextrestored. Phaser uses this to re-create necessary resources. Please wait for Phaser to dispatch the RESTORE_WEBGL event before re-creating any resources of your own.

Parameters:

name type description
renderer Phaser.Renderer.WebGL.WebGLRenderer

the renderer that owns the WebGL context

Since: 3.80.0
Focus
Focus