- IdleTimer
- IHintPlayer
- UserData
- Point
- Point
- PositionCallback
- Anchor
- ScaleCallback
- SafeScaleManager
- ResizeHelper
- ScaledEntity
- EntityResizeEvent
- ScaleManager
- SpeechSynth
- ColorFilter
- filterType
- KeyState
- Controller
- Key
- Application
- Debugger
- HintSequencePlayer
- Property
- Caption
- Caption
- CaptionFactory
- CaptionPlayer
- CaptionPlayer
- TimedLine
- IRender
- DOMRenderer
- HtmlRenderer
- TemplateRenderer
- TextRenderer
- Localizer
- Localizer.Options
- ApplicationPlugin
time
Number time in milliseconds (optional, default15000
)
Returns void @memberof IdleTimer
resets the timer, does not call subscribed functions
Returns void @memberof IdleTimer
Returns void @memberof IdleTimer
Calls all subscribed functions, and resets the timer.
Returns void @memberof IdleTimer
Adds a function to be called when timer is dispatched
callback
Returns void @memberof IdleTimer
Removes a function from being called when timer is dispatched
callback
any
Returns void @memberof IdleTimer
Hint Player interface to help enforce minimum requirements for hint players
play
function called by application to
Manages data between SpringRoll Container and SpringRoll
Gets data from SpringRoll Container
name
string
Returns Promise
Sends data to SpringRoll Container
name
stringvalue
any
Returns Promise
Removes data from SpringRoll Container
name
string
callback to used move game entities
Type: Function
position
Point position relative to anchor direction
Used to fix positions to a relative point in the viewport.
Returns void @memberof Anchor
callback to used scale game and canvas
Type: Function
width
Number width canvas should beheight
Number height canvas should bescale
Point x/y scale valuesscaleRatio
Number minimum aspect ratio that fit's in the screen.viewArea
Object Rectangle defining the total viewable area of game content.
Handles scaling the game
$0
Object$0.width
$0.height
$0.safeWidth
(optional, defaultInfinity
)$0.safeHeight
(optional, defaultInfinity
)$0.callback
(optional, default()=>{}
)
param
object
Type: Array<ScaledEntity>
Type: EntityResizeEvent
Removes an anchor
entity
ScaledEntity
Returns void @memberof SafeScaleManager
Enables the scale manager listener. Will not be enabled if a callback is not supplied.
callback
ScaleCallback The function to be called on resize events.
Disables the scale manager.
Calculates the offset for anchors.
scale
Point scale value
Returns Point
Adds and anchor to be updated during resize
entity
(ScaledEntity | Array<ScaledEntity>)
Utility class that handles resize events for ScaleManager and SafeScaleManager.
resizeCallback
function
Whether or not the application is running on an iOS device.
Returns the enabled state of the ResizeHelper.
Sets the enabled state of the ResizeHelper. Forces a resize event.
value
Handler for window resize events. Forwards this event to the scale manager if enabled.
Sets the window width and window height values of the ResizeHelper.
event
EntityResizeEvent
Returns void @memberof ScaledEntity
Type: {offset: Point, gameSize: Point, scale: Point}
Simplifies listening to resize events by passing the relevant data to a provided callback.
callback
Function (optional, defaultundefined
)
callback
Function?
Enables the scale manager listener. Will not be enabled if a callback is not supplied.
callback
Function The function to be called on resize events.
Disables the scale manager.
SpeechSync makes it easy to convert text to speech. Note: This is not supported on IE11 and below because of the underlying APIs are not implemented in those browsers
params
objectparams.voice
number Indicates what voice to use. (optional, default0
)params.rate
number The rate at which the text is said. Supports a range from 0.1 to 10. (optional, default1
)params.pitch
number Voice Pitch. Supports a pitch from 0 to 2. (optional, default0
)params.volume
number Volume. Supports 0 to 1. (optional, default1
)
voicesLoaded
boolean voices are loaded async. This is will be set to true when they are loaded.
Pauses the announcer.
Resumes the announcer.
Pauses the announcer and clears the queue.
Causes the announcer to say whatever message is passed to it. If the announcer is already saying something then it will be added to a queue.
message
string
Sets the voice by array index.
index
number
Returns the voice object.
Returns (object | null)
Rate at which text is spoken.
rate
number
Returns rate which text is spoken.
Returns number
Sets the pitch at which text is spoken.
pitch
number
Returns the pitch at which text is spoken.
Returns number
Sets the current volume of the announcer.
volume
number
Returns the current volume of the announcer.
Returns number
The Color filter allows you to simulate colorblindness.
Applies the specified filter to the element.
element
HTMLElementtype
filterType
Changes the currently applied filter to the element if the color filter has it.
type
filterType
Returns any
Removes the filter from the element.
Supported filter types.
Returns object Returns an object { name, value } with the colorblindness type: (Protanopia, Protanomaly, Deuteranopia, Deuteranomaly, Tritanopia, Tritanomaly, Achromatopsia, Achromatomaly)
Type: ("protanopia"
| "protanomaly"
| "deuteranopia"
| "deuteranomaly"
| "tritanopia"
| "tritanomaly"
| "achromatopsia"
| "achromatomaly"
)
Type: (0
| 1
| 2
)
Controller interface class to simplify working with key presses.
buttons
Array<KeyTemplate> An object containing all keys you want to watch and their functions. e.g. {enter: () => {}}. See https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values for potential values. (optional, default[]
)
Called on window blur, sets button state to up if button was down;
Returns void @memberof Controller
Calls all functions for buttons that are currently set to enabled.
Called on keyup. Sets flag to 1 if key is being watched.
Called on keyup. Sets flag to 2 if key is being watched.
Sets an object of button functions to the controller to be called.
keys
Array<KeyTemplate>
Represents a single key on the keyboard and the functions related to it.
key
string What this object represents.down
Function Function to be called while the key is held down. (optional, default()=>{}
)up
Function Function to be called when the key is lifted up. (optional, default()=>{}
)
state
(0
|1
|2
) The current state of the key. 0 = inactive, 1 = active, 2 = to be set to inactive.key
string The name of the key we are targeting.actions
object
Updates the internal state of the key. Accepts a range between 0-2. Will set key state to 0 if nothing is passed.
state
(0
|1
|2
) (optional, default0
)
Calls the relevant action for the current state of the key.
Returns the current state of the key.
Returns number
Main entry point for a game. Provides a single focal point for plugins and functionality to attach.
features
object A configuration object denoting which features are enabled for this applicationfeatures.captions
boolean? A boolean value denoting that this game supports captionsfeatures.sound
boolean? A boolean value denoting that this game has some audio in itfeatures.vo
boolean? A boolean denoting that this game has mutable voice-over audio in itfeatures.music
boolean? A boolean denoting that this game has mutable music in itfeatures.sfx
boolean? A boolean denoting that this game has mutable sound effects in itfeatures.soundVolume
boolean? A boolean denoting that this game has adjustable sound volume in itfeatures.musicVolume
boolean? A boolean denoting that this game has adjustable music volume in itfeatures.voVolume
boolean? A boolean denoting that this game has adjustable voice-over volume in itfeatures.sfxVolume
boolean? A boolean denoting that this game has adjustable sound effects volume in itfeatures.pointerSize
boolean? A boolean denoting that this game has adjustable pointer size in itfeatures.controlSensitivity
boolean? A boolean denoting that this game has adjustable control sensitivity in itfeatures.buttonSize
boolean? A boolean denoting that this game has adjustable button sizes in itfeatures.removableLayers
boolean? A boolean denoting that this game has removable game layers in itfeatures.hudPosition
boolean? A boolean denoting that this game has custom HUD positions.features.hitAreaScale
boolean? A boolean denoting that this game has adjustable hit areas.features.dragThresholdScale
boolean? A boolean denoting that this game has adjustable drag thresholds.features.health
boolean? A boolean denoting that this game has adjustable health.features.objectCount
boolean? A boolean denoting that this game has adjustable object count requirements.features.completionPercentage
boolean? A boolean denoting that this game has adjustable completion percentage requirements.features.speedScale
boolean? A boolean denoting that this game has adjustable speed.features.timersScale
boolean? A boolean denoting that this game has adjustable timers.features.inputCount
boolean? A boolean denoting that this game has adjustable input count requirements.features.keyBinding
boolean? A boolean denoting that this game has re-mappable key bindings.features.colorVision
boolean? A boolean denoting that this game has color blindess filters
returns instance of a plugin.
name
string
Returns (SpringRoll.ApplicationPlugin | undefined)
Validates that appropriate listeners are added for the features that were enabled in the constructor
- Throws any Error
Sets default values of application state properties.
preloads, initializes and starts plugins.
Returns Promise<void>
The list of plugins that are currently registered to run on Applications.
Registers a plugin to be used by applications, sorting it by priority order.
plugin
SpringRoll.ApplicationPlugin The plugin to register.
Finds a plugin by name.
name
string The name of the plugin.
Returns (SpringRoll.ApplicationPlugin | undefined)
Type: object
params
Object Optionsparams.emitEnabled
boolean If this should emit events to the window. (optional, defaultfalse
)params.minLevel
("GENERAL"
|"DEBUG"
|"INFO"
|"WARN"
|"ERROR"
) The starting log level for the logger. (optional, default'GENERAL'
)
Returns the params of the debugger.
Returns DebuggerParams
Sets the logging level of the debugger.
Returns void
If emitting is enabled for this instance, then it will dispatch an event on the window.
eventName
string Name of the event (optional, default'Debugger'
)
Returns logging levels.
Returns object
Console logs all supplied arguments if the log level is low enough for them to be logged.
type
("log"
|"general"
|"warn"
|"error"
|"debug"
|"info"
) minimum level for this log to run at (optional, default'log'
)args
Array<any> Arguments you wish to log.
Will throw if statement is false.
isTrue
boolean The expression to evaluate.
Returns a boolean indicating if the debugger has been enabled or not.
Returns boolean
Disables or enables all debugger instances. TODO: Remove the parameter here, and add a disable method as well
flag
boolean
Returns void
Returns the global params key.
invokes the next hint
Returns void @memberof HintSequencePlayer
removes all hints
Returns void @memberof HintSequencePlayer
callbacks
Array<function ()>
Returns void @memberof HintSequencePlayer
callbacks
Array<function ()>
Returns void @memberof HintSequencePlayer
A class for representing changeable/subscribable properties.
_value
any the value of the propertylisteners
[] all the objects listening to this property
Adds a subscriber to this property.
callback
function The callback to call whenever the property changes.
Unsubscribes a listener from this property.
callback
function The callback to unsubscribe.
Whether or not this property has any subscribed listeners
Returns Boolean True if this property has at least one subscriber
returns the current value of the property
Returns any
Sets the value of the property and notifies all listeners of the change
value
any the new property value
Updates content based on time passed.
This should be called every frame that the caption is active.
deltaTime
Number Time in seconds since last frame.
Handles calling callbacks and updating caption's current state.
Checks if caption has completed.
Returns Boolean
Sets time and line index of caption.
time
Number Time in milliseconds. (optional, default0
)renderer
(optional, default{lineBegin:()=>{},lineEnd:()=>{}}
)
Updates the current time and index of the caption instance
time
Number (optional, default0
)
lines
Updates content based on time passed.
This should be called every frame that the caption is active.
deltaTime
Number Time in seconds since last frame.
Handles calling callbacks and updating caption's current state.
Checks if caption has completed.
Returns Boolean
Sets time and line index of caption.
time
Number Time in milliseconds. (optional, default0
)renderer
(optional, default{lineBegin:()=>{},lineEnd:()=>{}}
)
Updates the current time and index of the caption instance
time
Number (optional, default0
)
Collection of functions for creating Captions
Creates a new Object<String, Caption>.
data
JSON
Returns Object
Creates a new Caption from JSON data.
captionData
any
Returns Caption new Caption
Creates a new TimedLine from JSON data.
lineData
any
Returns TimedLine new TimedLine;
CaptionPlayer is used to start, stop and update captions. It applies the content of an active caption to a given CaptionRenderer.
Updates any currently playing caption.
This should be called every frame.
deltaTime
Number Time passed in seconds since last update call.
Starts playing a caption.
name
String Name of caption.time
number Atart time in milliseconds. (optional, default0
)args
object Arguments that will get passed to the renderer (optional, default{}
)
Stops any caption currently playing.
captions
renderer
Updates any currently playing caption.
This should be called every frame.
deltaTime
Number Time passed in seconds since last update call.
Starts playing a caption.
name
String Name of caption.time
number Atart time in milliseconds. (optional, default0
)args
object Arguments that will get passed to the renderer (optional, default{}
)
Stops any caption currently playing.
Sets line's content. Removes HTML formatting for text.
content
any
Returns void @memberof TimedLine
Render interface to help enforce minimum requirements for caption renderers
start
function called when the Caption Player starts playing captionsstop
function called when the Caption Player stops playing captionslineBegin
function called when rendering a new line of textlineEnd
function called when finished rendering a new of text
DOMRender is a incomplete renderer that is intended to supply just the basic start and stop functions
element
HTMLElementtemplateVariables
Object
Makes target element visible and ready to present captions
templateVariables
object Variables that can used during caption play time (optional, default{}
)
H
HTML Renderer is intended for rendering raw html in the use case of wanting to display styled captions
Called by Caption Player when a new line needs to be displayed
line
Called by Caption Player when a line is complete
TemplateRenderer accepts a string template e.g.The ball is {{color}}
and a args object e.g. {color: 'red'}
and swaps out the placeholder inside the double brackets with the matching key inside the args object
template
string String template that will be rendered with the supplied argumentsargs
Object //An Object contain data to be inserted into the template This will match based on key values
Returns string
TextRenderer is intended for just rendering test. It will attempt to sanitize any strings passed to it by removing html syntax
Called by Caption Player when a new line needs to be displayed
line
Called by Caption Player when a line is complete
Will attempt to remove all html from a string before it's renderer to the page
html
any
path
stringoptions
any (optional, default{}
)
Returns {path: string, language: string}
localeKey
string
Returns boolean True if language is set.
localeKey
string
Returns boolean True if fallback is set.
localeKey
string
Returns string
Type: {language: string, fallback: string}
Represents a single plugin for applications. Allows developers to inject code in the start up process of an application providing new features to the application.
A preload method for the plugin which allows for asynchronous setup tasks. Either takes a callback as first parameter, or should return a Promise indicating that loading is finished.
Returns Promise A promise indicating when the plugin is finished loading.
An init method for the plugin. This method is ran synchronously in the constructor of the Application. After all plugins preloads has completed
A start method for the plugin. This method is ran synchronously in the constructor of the Application. After all plugins inits has completed