Class: Application

Application

Convenience class to create a new PixiJS application.

This class automatically creates the renderer, ticker and root container.

new Application ()

Create new Application instance

Example

 import { Application, Sprite } from 'pixi.js';

 // Create the application
 const app = new Application();

 await app.init({ width: 800, height: 600 });

 // Add the view to the DOM
 document.body.appendChild(app.canvas);

 // ex, add display objects
 app.stage.addChild(Sprite.from('something.png'));

Members

_plugins ApplicationPlugin[] static

Collection of installed plugins.

canvas HTMLCanvasElement readonly

Reference to the renderer's canvas element.

renderer Renderer

WebGL renderer if available, otherwise CanvasRenderer.

resizeTo Window | HTMLElement

The HTML element or window to automatically resize the renderer's view element to match width and height.

screen Rectangle readonly

Reference to the renderer's screen rectangle. Its safe to use as filterArea or hitArea for the whole screen.

stage Container

The root display container that's rendered.

ticker Ticker

Ticker for doing render updates.

Default Value:
  • Ticker.shared

view HTMLCanvasElement Deprecated : since 8.0.0

Reference to the renderer's canvas element.

Methods

destroy (rendererDestroyOptions, options) void

Destroys the application and all of its resources.

Name Type Attributes Default Description
rendererDestroyOptions object | boolean <optional>
false

The options for destroying the renderer.

rendererDestroyOptions.removeView boolean <optional>
false

Removes the Canvas element from the DOM.

options object | boolean <optional>
false

The options for destroying the stage.

options.children boolean <optional>
false

If set to true, all the children will have their destroy method called as well. options will be passed on to those calls.

options.texture boolean <optional>
false

Only used for children with textures e.g. Sprites. If options.children is set to true, it should destroy the texture of the child sprite.

options.textureSource boolean <optional>
false

Only used for children with textures e.g. Sprites. If options.children is set to true, it should destroy the texture source of the child sprite.

options.context boolean <optional>
false

Only used for children with graphicsContexts e.g. Graphics. If options.children is set to true, it should destroy the context of the child graphics.

init (options)

Name Type Attributes Description
options Partial<ApplicationOptions> <optional>

The optional application and renderer parameters.

render () void

Render the current stage.

resize () void

Execute an immediate resize on the renderer, this is not throttled and can be expensive to call many times in a row. Will resize only if resizeTo property is set.

start () void

Convenience method for starting the render.

stop () void

Convenience method for stopping the render.