springroll.native.NativeDisplay Class

NativeDisplay is a display plugin for doing native rendering. This represents the bare minimum needed by the Application to render.

Constructor

springroll.native.NativeDisplay

(
  • id
  • options
)

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

_enabled

Boolean private
If input is enabled on the stage.

RenderingContext public

Defined in :29

The main rendering context, typically either CanvasRenderingContext2d or WebGLRenderingContext

id

String public
The DOM id for the canvas

width

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

height

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

stage

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

paused

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

canvas

DOMElement public
the canvas managed by this display

_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

enabled

Boolean public
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.

visible

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

_listeners

Object private

The collection of listeners

_destroyed

Boolean protected

If the dispatcher is destroyed

destroyed

Boolean

If the dispatcher is destroyed

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