Class: Scene

Scene

new Scene(wrapper)

todoc
Parameters:
Name Type Description
wrapper HTMLElement
Properties:
Name Type Description
wrapper HTMLElement
screen Screen
cursor Cursor
settings PublicStorage
loader Loader
queue Queue
Source:

Extends

Members

(readonly) fps :int

The fps of the scene
Type:
  • int
Default Value:
  • 0
Source:

(readonly) lastTick :int

The last tick of the scene
Type:
  • int
Default Value:
  • 0
Source:

(readonly) readyState :String

The loading state of the scene
Type:
  • String
Default Value:
  • null
Source:

(readonly) run :Boolean

The running status of the scene
Type:
  • Boolean
Default Value:
  • false
Source:

(readonly) tickCount :int

The number of ticks
Type:
  • int
Default Value:
  • 0
Source:

(readonly) uuid :String

The uuid of the scene
Type:
  • String
Default Value:
  • null
Source:

Methods

addEventListener(type, listener) → {EventTarget}

Adds a listener to the specified event
Parameters:
Name Type Description
type String
listener function
Inherited From:
Source:
Returns:
EventTarget
this

addLayer(layer, orderIDopt) → {Scene}

Adds a Layer to the Scene
Parameters:
Name Type Attributes Description
layer Layer
orderID int <optional>
Source:
Returns:
Scene
this

addPlugin(pluginID, pluginConfigopt) → {Scene}

Adds a plugin to the scene
Parameters:
Name Type Attributes Description
pluginID String
pluginConfig Object <optional>
Source:
Returns:
Scene
this

addTask(listener, delayopt, thisArgopt) → {Task}

Adds a task to the queue
Parameters:
Name Type Attributes Description
listener function
delay int <optional>
thisArg Object <optional>
Source:
Returns:
Task

checkCollisions() → {Scene}

Calls each CollisionDetector check method from the watchList
Source:
Returns:
Scene
this

createAbstractElement(elemID, elementType, elementUseopt, argsopt) → {Scene}

Creates an AbstractElement
Parameters:
Name Type Attributes Description
elemID String
elementType String
elementUse Object <optional>
args Array <optional>
Source:
Returns:
Scene
this

createClass(className, classData) → {Scene}

Creates a new class
Parameters:
Name Type Description
className String
classData Object
Source:
Returns:
Scene
this

createLayer(layerUseopt) → {Layer}

Creates a new Layer and returns it
Parameters:
Name Type Attributes Description
layerUse Object <optional>
Source:
Returns:
Layer

dispatchEvent(type) → {EventTarget}

Dispatches an Event at the specified EventTarget
Parameters:
Name Type Description
type String
Inherited From:
Source:
Returns:
EventTarget
this

eachElement(callback) → {Scene}

Executes a provided callback function recursively once per Element in ascending order
Parameters:
Name Type Description
callback function
Source:
Returns:
Scene
this

eachEventListener(type, callback) → {EventTarget}

Executes a provided function once per event listener
Parameters:
Name Type Description
type String
callback function
Inherited From:
Source:
Returns:
EventTarget
this

eachLayer(callback) → {Scene}

Executes a provided callback function once per Layer in ascending order
Parameters:
Name Type Description
callback function
Source:
Returns:
Scene
this

emit(type) → {EventTarget}

Dispatches an Event at the specified EventTarget
Parameters:
Name Type Description
type String
Inherited From:
Source:
See:
Returns:
EventTarget
this

getDraggedElements() → {Array}

Returns an Array of currently dragged Elements
Source:
Returns:
Array

getFocusedElements() → {Array}

Returns an Array of currently hovered Elements
Source:
Returns:
Array

getLayer(layerId) → (nullable) {Layer}

Gets a Layer by id
Parameters:
Name Type Description
layerId String
Source:
Returns:
Layer

hasEventListener(type) → {Boolean}

Determines if the eventTarget has eventListeners of the given type
Parameters:
Name Type Description
type String
Inherited From:
Source:
Returns:
Boolean

include(data, callback) → {Scene}

Includes external data
Parameters:
Name Type Description
data String | Object
callback function
Source:
To Do:
  • XML support
Returns:
Scene
this

insertLayer(layerUseopt, orderIDopt) → {Layer}

Combination of Scene#createLayer and Scene#addLayer
Parameters:
Name Type Attributes Description
layerUse Object <optional>
orderID int <optional>
Source:
Returns:
Layer

later(listener, delay, thisArgopt) → {Scene}

Adds a task to the queue
Parameters:
Name Type Attributes Description
listener function
delay int
thisArg Object <optional>
Source:
Returns:
Scene
this

neglect(detector) → {Scene}

Removes the given CollisionDetector from the watchList
Parameters:
Name Type Description
detector CollisionDetector
Source:
Returns:
Scene
this

off(type, listener) → {EventTarget}

Removes a listener from the specified event
Parameters:
Name Type Description
type String
listener function
Inherited From:
Source:
See:
Returns:
EventTarget
this

offAll() → {EventTarget}

Removes all listeners
Inherited From:
Source:
See:
Returns:
EventTarget
this

on(type, listener) → {EventTarget}

Adds a listener to the specified event
Parameters:
Name Type Description
type String
listener function
Inherited From:
Source:
See:
Returns:
EventTarget
this

onScreen(element, partlyopt) → {Boolean}

Determines if a given element is on the screen
Parameters:
Name Type Attributes Default Description
element Element
partly Boolean <optional>
true
Source:
To Do:
  • Consider parent layer offset on collision check
  • Consider element rotation and scale on collision check
Returns:
Boolean

paint() → {Scene}

Displays the elements
Source:
Returns:
Scene
this

playAudio(audio, volumeopt, resetopt, callbackopt) → {Scene}

Plays an audio
Parameters:
Name Type Attributes Description
audio Audio | String
volume int <optional>
reset Boolean <optional>
callback function <optional>
Source:
Returns:
Scene
this

preload(path, components) → {Scene}

Loads components
Parameters:
Name Type Description
path String
components Object
Source:
Returns:
Scene
this

reflow() → {Scene}

Determines the elements position and size
Source:
Returns:
Scene
this

removeAllEventListeners() → {EventTarget}

Removes all listeners
Inherited From:
Source:
Returns:
EventTarget
this

removeEventListener(type, listener) → {EventTarget}

Removes a listener from the specified event
Parameters:
Name Type Description
type String
listener function
Inherited From:
Source:
Returns:
EventTarget
this

removeLayer(layer) → {Scene}

Removes a Layer from the Scene
Parameters:
Name Type Description
layer Layer
Source:
Returns:
Scene
this

removeTask(task) → {Scene}

Removes a task from the queue
Parameters:
Name Type Description
task Task
Source:
Returns:
Scene
this

repeat(listener, times, delayopt, thisArgopt) → {Scene}

Adds a task to the queue
Parameters:
Name Type Attributes Description
listener function
times int
delay int <optional>
thisArg Object <optional>
Source:
Returns:
Scene
this

resize(width, height) → {Scene}

Sets the size of the scene
Parameters:
Name Type Description
width int
height int
Source:
Returns:
Scene
this

setHeight(height) → {Scene}

Sets the height of the scene
Parameters:
Name Type Description
height int
Source:
Returns:
Scene
this

setWidth(width) → {Scene}

Sets the width of the scene
Parameters:
Name Type Description
width int
Source:
Returns:
Scene
this

start() → {Scene}

Starts the animation of the Scene
Source:
To Do:
  • Start scene on browser tab focus
  • "Play" queue tasks
Returns:
Scene
this

stop() → {Scene}

Stops the animation of the Scene
Source:
To Do:
  • Stop scene on browser tab blur
  • "Pause" queue tasks
Returns:
Scene
this

toString() → {String}

Returns the string value of the scene
Overrides:
Source:
Returns:
String

update() → {Scene}

Updates each element
Source:
Returns:
Scene
this

updateFocusedElements(e) → {Scene}

Updates the list of focused elements, emits the "mousemove", "mouseenter" and "mouseleave" events if necessary
Parameters:
Name Type Description
e MouseEvent
Source:
To Do:
  • Break forEach if the propagation is stopped
  • Consider parent layer offset on collision check
  • Consider element rotation and scale on collision check
Returns:
Scene
this

watch(element, targets, autoRemoveopt) → {CollisionDetector}

Creates a new CollisionDetector and adds it to the watchList
Parameters:
Name Type Attributes Description
element Element
targets *
autoRemove Boolean <optional>
Source:
Returns:
CollisionDetector