springroll.pixi.PixiDisplay Class

PixiDisplay is a display plugin for the springroll Framework that uses the Pixi library for rendering.

Constructor

springroll.pixi.PixiDisplay

(
  • id
  • options
)

Parameters:

  • id String

    The id of the canvas element on the page to draw to.

  • options Object

    The setup data for the Pixi stage.

    • [forceContext=null] String optional

      If a specific renderer should be used instead of WebGL falling back to Canvas. Use "webgl" or "canvas2d" to specify a renderer.

    • [clearView=false] Boolean optional

      If the canvas should be wiped between renders.

    • [backgroundColor=0x000000] Uint optional

      The background color of the stage (if it is not transparent).

    • [transparent=false] Boolean optional

      If the stage should be transparent.

    • [antiAlias=false] Boolean optional

      If the WebGL renderer should use anti-aliasing.

    • [preMultAlpha=false] Boolean optional

      If the WebGL renderer should draw with all images as pre-multiplied alpha. In most cases, you probably do not want to set this option to true.

    • [preserveDrawingBuffer=false] Boolean optional

      Set this to true if you want to call toDataUrl on the WebGL rendering context.

    • [autoPreventDefault=true] Boolean optional

      If preventDefault() should be called on all touch events and mousedown events.

destroy

()

Inherited from springroll.EventDispatcher but overwritten in destroy:216

Destroys the display. This method is called by the Application and should not be called directly, use Application.removeDisplay(id).

has

(
  • name
  • [callback]
)
Boolean

Checks if the EventDispatcher has a specific listener or any listener for a given event.

Parameters:

  • name String

    The name of the single event type to check for

  • [callback] Function optional

    The listener function to check for. If omitted, checks for any listener.

Returns:

Boolean:

If the EventDispatcher has the specified listener.

off

(
  • name
  • callback
)
EventDispatcher

Remove the event listener

Parameters:

  • name String*

    The type of event string separated by spaces, if no name is specifed remove all listeners.

  • callback Function | Array*

    The listener function or collection of callback functions

Returns:

EventDispatcher:

Return this EventDispatcher for chaining calls.

on

(
  • name
  • callback
  • [priority=0]
)
EventDispatcher

Add an event listener. The parameters for the listener functions depend on the event.

Parameters:

  • name String | Object

    The type of event (can be multiple events separated by spaces), or a map of events to handlers

  • callback Function | Array*

    The callback function when event is fired or an array of callbacks.

  • [priority=0] Int optional

    The priority of the event listener. Higher numbers are handled first.

Returns:

EventDispatcher:

Return this EventDispatcher for chaining calls.

once

(
  • name
  • callback
  • [priority=0]
)
EventDispatcher

Add an event listener but only handle it one time.

Parameters:

  • name String | Object

    The type of event (can be multiple events separated by spaces), or a map of events to handlers

  • callback Function | Array*

    The callback function when event is fired or an array of callbacks.

  • [priority=0] Int optional

    The priority of the event listener. Higher numbers are handled first.

Returns:

EventDispatcher:

Return this EventDispatcher for chaining calls.

render

(
  • elapsed
  • [force=false]
)

Inherited from springroll.AbstractDisplay but overwritten in render:201

Updates the stage and draws it. This is only called by the Application. This method does nothing if paused is true or visible is false.

Parameters:

  • elapsed Int
  • [force=false] Boolean optional

    Will re-render even if the game is paused or not visible

resize

(
  • width
  • height
)

Inherited from springroll.AbstractDisplay but overwritten in resize:189

Resizes the canvas and the renderer. This is only called by the Application.

Parameters:

  • width Int

    The width that the display should be

  • height Int

    The height that the display should be

trigger

(
  • type
  • arguments
)

Dispatch an event

Parameters:

  • type String

    The type of event to trigger

  • arguments

    Additional parameters for the listener functions.

type

(
  • value
)
String
private

Return type of the value.

Parameters:

  • value

Returns:

String:

The type

_autoPreventDefault

Boolean private

If preventDefault() should be called on all touch events and mousedown events. Defaults to true.

_destroyed

Boolean protected

If the dispatcher is destroyed

_enabled

Boolean private
If input is enabled on the stage.

_listeners

Object private

The collection of listeners

_visible

Boolean private
If the display is visible.

adapter

DisplayAdapter public
Some of the modules require a special display adapter to provide common methods for managing display objects.

Default: null

animator

springroll.Animator deprecated

Defined in animator:15

Deprecated: since version 0.4.0

See animator

autoPreventDefault

Boolean public

If preventDefault() should be called on all touch events and mousedown events. Defaults to true.

canvas

DOMElement public
the canvas managed by this display

destroyed

Boolean

If the dispatcher is destroyed

enabled

Boolean public

Inherited from springroll.AbstractDisplay but overwritten in enabled:135

If input is enabled on the stage for this display. The default is true.

height

Int public
Convenience method for getting the height of the canvas element would be the same thing as canvas.height

id

String public
The DOM id for the canvas

isWebGL

Boolean public

Defined in isWebGL:117

If Pixi is being rendered with WebGL.

keepMouseover

Boolean public

Defined in keepMouseover:49

If the display should keep mouse move events running when the display is disabled.

paused

Boolean public
If rendering is paused on this display only. Pausing all displays can be done using Application.paused setter.

renderer

PIXI.CanvasRenderer | PIXI.WebGLRenderer public

Defined in renderer:73

The Pixi renderer.

stage

PIXI.Stage public

Inherited from springroll.AbstractDisplay but overwritten in stage:65

The rendering library's stage element, the root display object

visible

Boolean public
If the display is visible, using "display: none" css on the canvas. Invisible displays won't render.

width

Int public
Convenience method for getting the width of the canvas element would be the same thing as canvas.width

disabled

If the display becomes disabled

enable

Enabled state changed on the display

Event Payload:

  • enabled Boolean
    Current state of enabled

enabled

If the display becomes enabled

hidden

If the display becomes hidden

visibility

Visibility changed on the display

Event Payload:

  • visible Boolean
    Current state of the visibility

visible

If the display becomes visible