springroll.AbstractDisplay Class

The display provides the base properties for all custom display. A display is a specialized view for the application. As the name suggests, this class should not be instanciated directly.

Constructor

springroll.AbstractDisplay

(
  • id
  • options
)
private

Parameters:

  • id String

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

  • options Object

    The setup data for the display.

    • [contextId="2d"] String optional

      Valid options are "2d" and "webgl"

destroy

()

Inherited from springroll.EventDispatcher but overwritten in destroy:214

Destroys the display. This method is called by the Application and should not be called directly, use Application.removeDisplay(id). The stage recursively removes all display objects here.

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]
)

Defined in render:202

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

    The time elapsed since the previous frame.

  • [force=false] Boolean optional

    For the re-render

resize

(
  • width
  • height
)

Defined in resize:190

Resizes the canvas. 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

_destroyed

Boolean protected

If the dispatcher is destroyed

_enabled

Boolean private

Defined in _enabled:79

If input is enabled on the stage.

_listeners

Object private

The collection of listeners

_visible

Boolean private

Defined in _visible:86

If the display is visible.

adapter

DisplayAdapter public

Defined in adapter:93

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

Default: null

canvas

DOMElement public

Defined in canvas:29

the canvas managed by this display

destroyed

Boolean

If the dispatcher is destroyed

enabled

Boolean public

Defined in enabled:106

If input is enabled on the stage for this display. The default is true. Without a rendering library, this does not actually have an effect.

height

Int public

Defined in height:54

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

id

String public

Defined in id:37

The DOM id for the canvas

paused

Boolean public

Defined in paused:71

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

stage

Mixed public

Defined in stage:63

The main rendering context or the root display object or stage.

visible

Boolean public

Defined in visible:148

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

width

Int public

Defined in width:45

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

disabled

Defined in disabled:132

If the display becomes disabled

enable

Defined in enable:138

Enabled state changed on the display

Event Payload:

  • enabled Boolean

    Current state of enabled

enabled

Defined in enabled:127

If the display becomes enabled

hidden

Defined in hidden:174

If the display becomes hidden

visibility

Defined in visibility:180

Visibility changed on the display

Event Payload:

  • visible Boolean

    Current state of the visibility

visible

Defined in visible:169

If the display becomes visible