springroll

2.9.0

IdleTimer

new IdleTimer()
Instance Members
start(time)
reset()
stop()
dispatch()
subscribe(callback)
unsubscribe(callback)

UserData

Manages data between SpringRoll Container and SpringRoll

new UserData()
Static Members
read(name)
write(name, value)
delete(name)

DateUtil

Utility class for date-related operations.

new DateUtil()
Static Members
isInSeason(startDate, endDate)

Point

Point

Type: {x: Number, y: Number}

Point

Point

Type: {x: Number, y: Number}

PositionCallback

callback to used move game entities

PositionCallback(position: Point)

Type: Function

Parameters
position (Point) position relative to anchor direction

Anchor

Used to fix positions to a relative point in the viewport.

new Anchor()
Instance Members
onResize(param)

ScaleCallback

callback to used scale game and canvas

ScaleCallback(width: Number, height: Number, scale: Point, scaleRatio: Number, viewArea: Object)

Type: Function

Parameters
width (Number) width canvas should be
height (Number) height canvas should be
scale (Point) x/y scale values
scaleRatio (Number) minimum aspect ratio that fit's in the screen.
viewArea (Object) Rectangle defining the total viewable area of game content.

SafeScaleManager

Handles scaling the game

new SafeScaleManager($0: Object, param: object)
Parameters
$0 (Object)
Name Description
$0.width any
$0.height any
$0.safeWidth any (default Infinity)
$0.safeHeight any (default Infinity)
$0.callback any (default ()=>{})
param (object)
Static Members
calcOffset(scale)
addEntity(entity)
Instance Members
entities
resizeEventData
removeEntity(entity)
enable(callback)
disable()

ResizeHelper

Utility class that handles resize events for ScaleManager and SafeScaleManager.

new ResizeHelper(resizeCallback: function)
Parameters
resizeCallback (function)
Static Members
iOS
enabled
enabled
onWindowResize()
getWindowResolution()

EntityResizeEvent

EntityResizeEvent

Type: {offset: Point, gameSize: Point, scale: Point}

ScaledEntity

ScaledEntity
Instance Members
onResize(event)

ScaleManager

[Deprecated]

Simplifies listening to resize events by passing the relevant data to a provided callback.

new ScaleManager(callback: Function)
Parameters
callback (Function = undefined)
Properties
callback (Function?)
Instance Members
enable(callback)
disable()

SpeechSynth

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

new SpeechSynth(params: object)
Parameters
params (object)
Name Description
params.voice number (default 0) Indicates what voice to use.
params.rate number (default 1) The rate at which the text is said. Supports a range from 0.1 to 10.
params.pitch number (default 0) Voice Pitch. Supports a pitch from 0 to 2.
params.volume number (default 1) Volume. Supports 0 to 1.
Properties
voicesLoaded (boolean) : voices are loaded async. This is will be set to true when they are loaded.
Instance Members
pause()
resume()
cancel()
say(message)
setVoice(index)
getVoice()
rate
rate
pitch
pitch
volume
volume

filterType

filterType

Type: ("protanopia" | "protanomaly" | "deuteranopia" | "deuteranomaly" | "tritanopia" | "tritanomaly" | "achromatopsia" | "achromatomaly")

ColorFilter

The Color filter allows you to simulate colorblindness.

new ColorFilter()
Static Members
applyFilter(element, type)
changeFilter(type)
removeFilter()
types

KeyState

KeyState

Type: (0 | 1 | 2)

Properties
down (Function)
up (Function)
key (string)

Controller

Controller interface class to simplify working with key presses.

new Controller(buttons: Array<KeyTemplate>)
Parameters
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.
Static Members
update()
onKeyDown(e)
onKeyUp(e)
assignButtons(keys)
Instance Members
onWindowBlur()

Key

Represents a single key on the keyboard and the functions related to it.

new Key(key: string, down: Function, up: Function)
Parameters
key (string) What this object represents.
down (Function = ()=>{}) Function to be called while the key is held down.
up (Function = ()=>{}) Function to be called when the key is lifted up.
Properties
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)
  • actions.down function

    Function to be called while the key is held down.

  • actions.up function

    Function to be called when the key is lifted up.

Static Members
updateState(state)
action()
state

Application

Main entry point for a game. Provides a single focal point for plugins and functionality to attach.

new Application()
Properties
features (object) : A configuration object denoting which features are enabled for this application
  • features.captions boolean?

    A boolean value denoting that this game supports captions

  • features.sound boolean?

    A boolean value denoting that this game has some audio in it

  • features.vo boolean?

    A boolean denoting that this game has mutable voice-over audio in it

  • features.music boolean?

    A boolean denoting that this game has mutable music in it

  • features.sfx boolean?

    A boolean denoting that this game has mutable sound effects in it

  • features.soundVolume boolean?

    A boolean denoting that this game has adjustable sound volume in it

  • features.musicVolume boolean?

    A boolean denoting that this game has adjustable music volume in it

  • features.voVolume boolean?

    A boolean denoting that this game has adjustable voice-over volume in it

  • features.sfxVolume boolean?

    A boolean denoting that this game has adjustable sound effects volume in it

  • features.pointerSize boolean?

    A boolean denoting that this game has adjustable pointer size in it

  • features.controlSensitivity boolean?

    A boolean denoting that this game has adjustable control sensitivity in it

  • features.buttonSize boolean?

    A boolean denoting that this game has adjustable button sizes in it

  • features.removableLayers boolean?

    A boolean denoting that this game has removable game layers in it

  • features.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

  • features.fullScreen boolean?

    A boolean denoting that this game has fullScreen capabilities

Static Members
setupPlugins()
_plugins
uses(plugin)
getPlugin(name)
Instance Members
getPlugin(name)
validateListeners()
setStateDefaults()

Debugger

new Debugger(params: Object)

Type: object

Parameters
params (Object) Options
Name Description
params.emitEnabled boolean (default false) If this should emit events to the window.
params.minLevel ("GENERAL" | "DEBUG" | "INFO" | "WARN" | "ERROR") (default 'GENERAL') The starting log level for the logger.
Properties
emitEnabled (boolean)
enabled (boolean)
minLevel (number)
Static Members
params
minLevel(level)
emit(eventName)
LEVEL
log(type, args)
assert(isTrue)
isEnabled()
enable(flag)
paramKey

HintSequencePlayer

new HintSequencePlayer()
Instance Members
play()
clear()
add(callbacks)
remove(callbacks)

IHintPlayer

Hint Player interface to help enforce minimum requirements for hint players

new IHintPlayer()
Properties
play (function) : called by application to

Property

A class for representing changeable/subscribable properties.

new Property()
Properties
_value (any) : the value of the property
listeners ([]) : all the objects listening to this property
alwaysNotify (boolean) : Determines if the property will notify a value change regardless if it's a new value or not.
Instance Members
value
value
subscribe(callback)
unsubscribe(callback)
hasListeners

Caption

new Caption(lines: any)
Parameters
lines (any)
Static Members
update(deltaTime)
updateState(currentTime, lastTime)
isFinished()
start(time, renderer)
updateTimeIndex(time)

Caption

new Caption()
Properties
lines (Array<TimedLine>)
time (number)
lineIndex (number)
renderer (IRender)
Static Members
update(deltaTime)
updateState(currentTime, lastTime)
isFinished()
start(time, renderer)
updateTimeIndex(time)

CaptionFactory

Collection of functions for creating Captions

new CaptionFactory()
Static Members
createCaptionMap(data)
createCaption(captionData)
createLine(lineData)

CaptionPlayer

new CaptionPlayer(captions: any, renderer: any)
Parameters
captions (any)
renderer (any)
Static Members
update(deltaTime)
start(name, time, args)
stop()

CaptionPlayer

CaptionPlayer is used to start, stop and update captions. It applies the content of an active caption to a given CaptionRenderer.

new CaptionPlayer()
Static Members
update(deltaTime)
start(name, time, args)
stop()

TimedLine

new TimedLine()
Properties
startTime (number)
endTime (number)
content (string)
Instance Members
setContent(content)

IRender

Render interface to help enforce minimum requirements for caption renderers

new IRender()
Properties
start (function) : called when the Caption Player starts playing captions
stop (function) : called when the Caption Player stops playing captions
lineBegin (function) : called when rendering a new line of text
lineEnd (function) : called when finished rendering a new of text

DOMRenderer

DOMRender is a incomplete renderer that is intended to supply just the basic start and stop functions

new DOMRenderer(element: HTMLElement, templateVariables: Object)
Parameters
element (HTMLElement)
templateVariables (Object)
Static Members
start(templateVariables)
stop()

HtmlRenderer

HTML Renderer is intended for rendering raw html in the use case of wanting to display styled captions

new HtmlRenderer()
Static Members
lineBegin(line)
lineEnd()

TemplateRenderer

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

new TemplateRenderer(template: string, args: Object): string
Parameters
template (string) String template that will be rendered with the supplied arguments
args (Object) //An Object contain data to be inserted into the template This will match based on key values
Returns
string:

TextRenderer

TextRenderer is intended for just rendering test. It will attempt to sanitize any strings passed to it by removing html syntax

new TextRenderer()
Static Members
lineBegin(line)
lineEnd()
sanitize(html)

Localizer.Options

Localizer.Options

Type: {language: string, fallback: string}

Localizer

new Localizer()
Static Members
resolve(path, options)
setPrimaryLocale(localeKey)
setFallbackLocale(localeKey)
getLocaleKey(localeKey)
getBrowserLanguages()

ApplicationPlugin

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.

new ApplicationPlugin()
Instance Members
preload()
init()
start()