Class: Application

PIXI.Application

Convenience class to create a new PIXI application.

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

new PIXI.Application (options)

Name Type Description
options object optional

The optional renderer parameters.

Name Type Default Description
autoStart boolean true optional

Automatically starts the rendering after the construction. Note: Setting this parameter to false does NOT stop the shared ticker even if you set options.sharedTicker to true in case that it is already started. Stop it by your own.

width number 800 optional

The width of the renderers view.

height number 600 optional

The height of the renderers view.

view HTMLCanvasElement optional

The canvas to use as a view, optional.

transparent boolean false optional

If the render view is transparent.

autoDensity boolean false optional

Resizes renderer view in CSS pixels to allow for resolutions other than 1.

antialias boolean false optional

Sets antialias

preserveDrawingBuffer boolean false optional

Enables drawing buffer preservation, enable this if you need to call toDataUrl on the WebGL context.

resolution number 1 optional

The resolution / device pixel ratio of the renderer, retina would be 2.

forceCanvas boolean false optional

Prevents selection of WebGL renderer, even if such is present. This option is only available in the pixi.js-legacy package.

backgroundColor number 0x000000 optional

The background color of the rendered area (shown if not transparent).

clearBeforeRender boolean true optional

This sets if the renderer will clear the canvas or not before the new render pass.

forceFXAA boolean false optional

Forces FXAA antialiasing to be used over native. FXAA is faster, but may not always look as great. (WebGL only).

powerPreference string optional

Parameter passed to webgl context, set to "high-performance" for devices with dual graphics card. (WebGL only).

sharedTicker boolean false optional

true to use PIXI.Ticker.shared, false to create new ticker.

sharedLoader boolean false optional

true to use PIXI.Loaders.shared, false to create new Loader.

resizeTo Window | HTMLElement optional

Element to automatically resize stage to.

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

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

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

Members

loader PIXI.Loader readonly

Loader instance to help with asset loading.

WebGL renderer if available, otherwise CanvasRenderer.

resizeTo Window | HTMLElement

The element or window to resize the application to.

screen PIXI.Rectangle readonly

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

The root display container that's rendered.

ticker PIXI.Ticker

Ticker for doing render updates.

Default Value:
  • PIXI.Ticker.shared

view HTMLCanvasElement readonly

Reference to the renderer's canvas element.

Methods

PIXI.Application.registerPlugin (plugin) static

Register a middleware plugin for the application

Name Type Description
plugin PIXI.Application.Plugin

Plugin being installed

createRenderer (options) protected

Create the new renderer, this is here to overridden to support Canvas.

Name Type Description
options Object optional

See constructor for complete arguments

destroy (removeView, stageOptions)

Destroy and don't use after this.

Name Type Default Description
removeView Boolean false optional

Automatically remove canvas from DOM.

stageOptions object | boolean optional

Options parameter. A boolean will act as if all options have been set to that value

Name Type Default Description
children boolean false optional

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

texture boolean false optional

Only used for child Sprites if stageOptions.children is set to true. Should it destroy the texture of the child sprite

baseTexture boolean false optional

Only used for child Sprites if stageOptions.children is set to true. Should it destroy the base texture of the child sprite

render ()

Render the current stage.

resize ()

If resizeTo is set, calling this function will resize to the width and height of that element.

Convenience method for starting the render.

Convenience method for stopping the render.

Type Definitions

PIXI.Application.Plugin object

Properties:
Name Type Description
init function

Called when Application is constructed, scoped to Application instance. Passes in options as the only argument, which are Application constructor options.

destroy function

Called when destroying Application, scoped to Application instance