Constructors

- Wade

Constructor Summary

Wade()
WADE - Web App Development Engine

Fields Summary

app
app
The current app instance
c_timeStep
c_timeStep
The time (in seconds) between simulation steps
defaultLayer
defaultLayer
The default layer for new sprites.

Functions Summary

addEventListener
(sceneObject,
event)
Register a scene object to listen for all the events with a given name.
addGlobalEventListener
(sceneObject,
event)
Register a scene object to listen for all the events with a given name.
addPath
(path)
Add a Path to the scene
addSceneObject
(sceneObject,
autoListen,
params)
Add a scene object to the scene
ajax
(params)
Perform an asynchronous HTTP request
Check to see if gamepads are supported in the current browser
autoLoadImages
(toggle)
Set whether WADE should try to automatically load images that haven't yet been loaded when the app is trying to use them.
Do not allow the App to be linked from selected domains
boxContainsBox
(box1,
box2)
Check whether box1 contains box2
boxContainsPoint
(box,
point)
Check whether a box contains a point
boxIntersectsBox
(box1,
box2)
Check whether box1 and box2 intersect each other
Check whether an axis-aligned box and an oriented box overlap each other.
Stop the normal input event handling by the browser.
canvasBoxToWorld
(layerId,
box)
Transform a canvas space box into world space
canvasDirectionToWorld
(layerId,
direction)
Transform a canvas space direction into world space
canvasPositionToWorld
(layerId,
position)
Transform a canvas space position into world space
Get the size of a canvas pixel in world-space units
clampBoxToBox
(box1,
box2)
Resize box1 so that it's fully contained in box2
Remove any active timeouts or intervals that have been set via wade.setTimeout() or wade.setInterval()
clearCanvas
(layerId)
Clear the canvas(es) associated with a specific layer.
clearInterval
(intervalUid)
Cancel an interval that was previously scheduled with wade.setInterval()
Remove all the scene objects from the scene
Stop and delete all timelines
clearTimeout
(timeoutUid)
Cancel a timeout that was previously scheduled with wade.setTimeout()
cloneArray
(array)
Clone an array
cloneObject
(object)
Clone an object
createCanvas
(resolutionFactor)
Create an HTML5 canvas object and add it to the document
createPseudoArray
(maxLength,
onSet)
Create a pseudo-array, i.e.
createTransparentImage
(imageName,
width,
height)
Create a transparent image
Delete all the canvas objects created by WADE
draw
(layerIds)
Draw a layer, group of layers, or the whole scene.
drawLayerToImage
(layerId,
imageName,
replace,
offset,
transform,
compositeOperation)
Draw a layer to an image in CPU memory
Enable or disable double buffering for the on-screen canvases.
enableGamepads
(toggle)
Enabled or disable gamepad support
Enable or disable support for multi touch.
error
(data)
A function to log any error message from WADE.
expandBox
(box1,
box2)
Expand box1 so that it encompasses both box1 and box2
exportScene
(stringify,
exclude,
exportObjectFunctions)
Export the current scene to an object (optionally serializing it to a JSON string), that can then be used to import a scene like the current one, through wade.importScene()
fadeInLayer
(layerId,
time,
callback)
Fade in a layer over time
fadeOutLayer
(layerId,
time,
callback)
Fade out a layer over time
forceOrientation
(orientation)
Force the app to be displayed in a certain orientation.
forceRedraw
(layerId)
Force the full redraw of the scene (or of a single layer)
forEachPixel
(sourceImage,
whatToDo,
targetImage)
Apply a per-pixel transformation to an image.
Get a list of the id's of all layers that are currently active (including empty ones)
Get the total simulation time, in seconds, since the app was started
Get the base path of the app (i.e.
Get the current camera position.
Retrieve the length of the catch-up buffer, that is how many seconds of lag should be tolerated before WADE stops trying to catch up with missed frames
Get the current system clock time in millisecond.
Get the height of the window that contains the app
Get the name of the DIV or the HTML element that contains the App.
Get the width of the window that contains the app
getFont
(file)
Get the base64-encoded dataURL of a font
Checks if the app is being displayed in forced orientation mode.
Get the full path and file name of the specified file.
Get the host name based on a URL string
getImage
(file,
errorMessage)
Get an image object that has previously been loaded, or a blank image
getImageData
(file,
posX,
posY,
width,
height)
Get the raw data of an image file or canvas, as an array of bytes
getImageDataURL
(imageName)
Generate a data URL from an image that had previously been loaded or procedurally generated
getJson
(file)
getKeyCode
(keyName)
Get the numerical key code associated with a key name, or 0 if the name isn't valid
getKeyName
(keyCode)
Get the key name associated with a numerical key code
getLayerCanvas
(layerId)
Get the canvas object being used by a layer.
Get the entire set of custom properties of a layer
getLayerCustomProperty
(layerId,
key)
Retrieve the value of a custom property of a layer
getLayerDataURL
(layerId)
Generate a data URL from a game layer
getLayerOpacity
(layerId)
Get the opacity of a layer.
Get the current render mode of a layer.d
Get the resolution factor for a specific layer
Get the current image smoothing state for a specific layer
getLayerSorting
(layerId)
Get the sorting method that is currently being used for the layer
Get the percentage of files that have been fully loaded with respect to the number of files for which a loading operation has been requested
Get the current loading status of a file
Get the maximum height of the render area
Get the maximum width of the render area
Get the minimum height of the render area
Get the minimum width of the render area
Get the current mouse position, or the position of the last input event (in the case of touch events).
getObjectsInArea
(area,
layerId)
Get the objects inside (or intersecting) the specified area, expressed in world units
Get the objects inside (or intersecting) the specified area, expressed in screen units
getPath
(name)
Get a path, given its name as a string
getPaths
(property,
value)
Get a list of all the paths in the scene, or just the paths with a given property/value pair.
Get the post process shader code being used by a layer
Get the post process shader uniforms being used by a layer
This function can only be used in debug mode to get the details of a timeline event that has been processed.
Get the current global resolution factor.
Get a scene object by name.
getSceneObjectIndex
(sceneObject)
Get the current index of a scene object in the scene.
getSceneObjects
(property,
value)
Get a list of all the objects in the scene, or just the objects with a given property/value pair.
Get the hight of the current render area
Get the width of the current render area
getScript
(file)
Get the contents of a script file
Get the "global" image smoothing state.
getSpritesInArea
(area,
layerId,
sorted)
Get the sprites inside (or intersecting) the specified area, expressed in world units
Get the sprites inside (or intersecting) the specified area, expressed in screen units
getText
(file)
Get a reference to all the timelines, active and inactive.
Get the current version of WADE as a string.
If WebAudio is supported, get the current WebAudio context
Get the current window mode.
hashString
(str)
Get a 32-bit integer hash of a given string
importScene
(data,
loadingBar,
callback,
async,
clearScene)
Import a scene from an object that contains a description of all the entities in the scene - it could have been previously exported with wade.exportScene(), or edited manually.
init
(appScript,
appData,
options)
Initialize the engine
Initialize the user app.
Create an instance of the user app.
Checks whether the init function for the app has been executed
isArray
(a)
Check whether an object is an Array
Check whether WADE is automatically trying to load images that haven't yet been loaded when the app is trying to use them.
Check whether we are currently running in debug mode
Check the current state of double buffering.
isEventListener
(sceneObject,
event)
Check to see if a Scene Object is currently listening for a specific type of event
isKeyDown
(keyCode)
Check whether a key is currently down (it's being pressed by the user).
isMouseDown
(buttonId)
Check whether a mouse button is currently pressed.
Check whether multi touch support is current enabled.
Checks whether the screen is rotated, with respect to the orientation that was set with forceOrientation().
isUsingQuadtree
(layerId)
Check whether a layer is using quadtree-based optimizations
Checks whether the WebAudio API is supported by the client
Check to see if WebGL is supported
loadAudio
(file,
autoplay,
looping,
callback,
errorCallback)
Load an audio file.
loadFont
(file,
callback,
errorCallback)
Load a font file.
loadImage
(file,
callback,
errorCallback)
Load an image file.
loadImages
(arrayOfFileNames)
This is a helper functions to load multiple images in a single function call, and is equivalent to calling wade.loadImage() multiple times.
loadJson
(file,
objectToStoreData,
callback,
forceReload,
errorCallback)
Load a JavaScript Object Notation (JSON) data file.
loadPage
(url)
Open a web page in the app's window.
loadScene
(fileName,
loadingBar,
callback,
clearScene)
Load a JSON file that contains the description of a wade scene, and process that file to load any assets being used and instantiate SceneObjects, Sprites, TextSprites and Animations according to the scene description.
loadScript
(file,
callback,
forceReload,
errorCallback,
dontExecute)
Load a javascript file.
loadText
(file,
objectToStoreData,
callback,
forceReload,
errorCallback)
Load a plain text file.
log
(data)
A function to log any message from WADE.
moveCamera
(destination,
speed,
callback)
Gradually move the camera to the specified position, with the specified speed.
Check whether an oriented box contains a point
Check whether an axis-aligned box and an oriented box overlap each other.
Check whether two oriented boxes intersect each other.
pauseSimulation
(mainLoopName)
Pause the simulation
playAudio
(file,
looping,
callback)
Play an audio file that has previously been loaded with a call to loadAudio or preloadAudio
playAudioSegment
(file,
start,
end,
callback)
Play a segment of an audio file
postObject
(url,
object,
callback,
extraParameters)
Send an object to a server.
preloadAudio
(file,
autoplay,
looping,
callback,
errorCallback)
Load an audio file asynchronously, without suspending the simulation.
preloadFont
(file,
callback,
errorCallback)
Load a font file asynchronously, without suspending the simulation.
preloadImage
(file,
callback,
errorCallback)
Load an image file asynchronously, without suspending the simulation.
preloadJson
(file,
objectToStoreData,
callback,
forceReload,
errorCallback)
Load a JavaScript Object Notation (JSON) data file asynchronously, without suspending the simulation.
preloadScene
(fileName,
loadingBar,
callback,
clearScene)
Load a JSON file that contains the description of a wade scene, and process that file to load any assets being used and instantiate SceneObjects, Sprites, TextSprites and Animations according to the scene description.
preloadScript
(file,
callback,
forceReload,
errorCallback,
dontExecute)
Load a javascript file asynchronously, without suspending the simulation.
preloadText
(file,
objectToStoreData,
callback,
forceReload,
errorCallback)
Load a plain text file asynchronously, without suspending the simulation.
Prevent the WADE App from being executed inside an iframe
processEvent
(event,
eventData)
Process a given event.
putImageData
(file,
data,
destX,
destY,
sourceX,
sourceY,
width,
height)
Write raw data into an image or canvas resource.
Recreate canvas objects that were delete with a call to wade.deleteCanvases
removeEventListener
(sceneObject,
event)
Unregister an object that has previously been registered to listen for an event using addEventListener.
removeGlobalEventListener
(sceneObject,
event)
Unregister an object that has previously been registered to listen for an event using addGlobalEventListener.
removeLayer
(layerId)
Remove a layer that was previously created, and free all the associated resources
removeObjectFromArray
(object,
array)
Remove an object from an array
Remove an object from an array based on the object's index into the array
removePath
(path)
Remove a Path from the scene
removeSceneObject
(sceneObject)
Remove a scene object from the scene
removeSceneObjects
(sceneObjects)
Remove multiple scene objects from the scene
removeUnusedLayers
(exceptions)
Remove all layers that contain no sprites, and release all the associated resources
requireVersion
(requiredVersion,
errorMode,
errorMessage)
Ensure that the current version of WADE is greater or equal than a specific version.
Restart listening to input events after a call to wade.stopInputEvents()
resumeSimulation
(mainLoopName)
Resume the simulation (typically after it was paused via wade.pauseSimulation)
resumeTimeline
(timelineId)
Resume an inactive timeline
Retrieve an object from the local storage, that has previously been saved through storeLocalObject()
runFlowChart
(flowChartData,
startNode,
precompile,
delay,
parentObject)
Execute a flow chart
screenBoxToWorld
(layerId,
box)
Transform a screen space box into world space
screenCapture
(imageName)
Draw the contents of the WADE screen to an image in CPU memory
screenDirectionToWorld
(layerId,
direction)
Transform a screen space direction into world space
screenPositionToWorld
(layerId,
position)
Transform a screen space position into world space
Get the size of a screen pixel in world-space units
Set a custom interval for the 'onAppTimer' event.
setAudio
(file,
audio,
callback,
setForPreloader)
Associate a file name with an audio object, so that any subsequent calls to getAudio using the given file name will return that object.
setBasePath
(path)
Set the base path of the app.
Set a world space position for the camera.
setCameraTarget
(target,
inertia,
offset)
Set a scene object for the camera to follow.
setCanvasClearing
(layerId,
toggle)
Determine whether the canvas (or the portions of it that have changed) should be cleared between frames.
setCatchUpBuffer
(bufferTime)
Set how many seconds of lag should be tolerated before WADE stop trying to catch up with missed frames
setClickTolerance
(tolerance)
Set a tolerance for "onClick" events.
setFont
(file,
data,
setForPreloader)
Associate a file name with a font, so that any subsequent calls to getFont using the given file name will return that font.
setFullScreen
(toggle)
Toggle full screen mode.
Set a callback to be executed when all the pending loading requests terminate.
setImage
(file,
image,
setForPreloader)
Associate a file name with an image object, so that any subsequent calls to getImage using the given file name will return that object.
setInterval
(f,
time)
Schedule the periodic execution of a function.
setJson
(file,
data,
setForPreloader)
Associate a file name with a JSON object, so that any subsequent calls to getJson using the given file name will return that object.
setLayer3DTransform
(layerId,
transformString,
transformOrigin,
time,
callback)
Set a CSS 3D transform on a layer.
setLayerCustomProperties
(layerId,
properties)
Set a set of custom properties for a layer.
setLayerCustomProperty
(layerId,
key,
value)
Set a custom property for a layer.
setLayerOpacity
(layerId,
opacity)
Set the opacity of a layer.
setLayerRenderMode
(layerId,
renderMode,
options)
Set the render mode for a layer
setLayerResolutionFactor
(layerId,
resolutionFactor)
Set the resolution factor for a specific layer
setLayerSmoothing
(layerId,
toggle)
Enable or disable image smoothing for a specific layer.
setLayerSorting
(layerId,
sortingType)
Set the sorting method to use for a specified layer
setLayerTransform
(layerId,
scale,
translate)
Set a coordinate transformation for the layer.
setLoadingBar
(visible,
position,
backColor,
foreColor)
Display (or hide) a progress bar that indicates the current loading progress
setLoadingImages
(files,
link)
Set the loading image(s) to be displayed while loading data
setMainLoop
(callback,
name,
priority)
Set or remove a callback to be executed after each simulation step.
setMaxScreenSize
(width,
height)
Set the maximum width and height of the render area.
Set the minimum time between input events of the same type.
setMinScreenSize
(width,
height)
Set the minimum width and height of the render area.
setPostProcessShader
(layerId,
shaderSource,
shaderUniforms)
Set a post-process shader for a layer
setResolutionFactor
(_resolutionFactor)
Set the resolution factor for all layers
setSceneObjectIndex
(sceneObject,
index)
Set the index of a scene object in the scene.
setScreenSize
(width,
height)
Set the size of the render area.
setScript
(file,
data,
setForPreloader)
Associate a file name with a script, so that any subsequent calls to getScript using the given file name will return that script.
setSmoothing
(toggle)
Enable or disable image smoothing for all layers.
setSwipeTolerance
(tolerance,
numSamples)
Set the tolerance for swipe events.
setText
(file,
data,
setForPreloader)
Associate a file name with a text string, so that any subsequent calls to getText using the given file name will return that string.
setTimeout
(f,
time)
Schedule the execution of a function.
Set the current window mode.
simulateSceneObject
(sceneObject,
toggle)
Enable or disable the simulation of a scene object
siteLock
(domain)
Only allow the WADE App to be executed on a specific domain.
Skip any frames that have been missed due to lag up to this point (don't try to catch up).
startTimeline
(timeline,
time,
timelineId)
Start a timeline.
stop()
Stop the execution of the WADE app.
stopAudio
(uid)
Stop an audio file that was playing
Stop listening for input events
stopTimeline
(timelineId)
Stop an active timeline
storeLocalObject
(name,
object)
Store an object or array in the local storage.
Release references to all the audio files that have been loaded so far, so they can be garbage-collected to free some memory
Release references to all the image files that have been loaded so far, so they can be garbage-collected to free some memory
unloadAudio
(file)
Release references to an audio file, so it can be garbage-collected to free some memory
unloadImage
(file)
Release references to an image file, so it can be garbage-collected to free some memory
unpackSpriteSheet
(spriteSheet,
destinations,
numCellsX,
numCellsY,
unload)
Create a separate image (more specifically an off-screen canvas) for each sprite in the sprite sheet
useQuadtree
(layerId,
toggle)
Enable or disable quadtree optimization for a specific layer.
warn
(data)
A function to log any warning message from WADE.
Only allow the App to be linked only from selected domains
worldBoxToCanvas
(layerId,
box)
Transform a world space box into canvas space
worldBoxToScreen
(layerId,
box)
Transform a world space box into screen space
worldDirectionToCanvas
(layerId,
direction)
Transform a world space direction into canvas space
worldDirectionToScreen
(layerId,
direction)
Transform a world space direction into screen space
worldPositionToCanvas
(layerId,
position)
Transform a world space position into canvas space
worldPositionToScreen
(layerId,
position)
Transform a world space position into screen space
Get the size (in canvas pixels) of a world-space unit
Get the size (in screen pixels) of a world-space unit

Constructor Details

()
WADE - Web App Development Engine

Fields Details


The current app instance


The time (in seconds) between simulation steps


The default layer for new sprites. This is initially set to 1.

Function Details


(sceneObject,
event)
Register a scene object to listen for all the events with a given name. When an event is triggered, a callback with the same name as the event will be called for this object and all its behaviors (when present). When input events (such as onClick) occur outside the bounding boxes of the objects' sprites, the scene object will not receive the event.

Parameters:


{SceneObject}sceneObject
A scene object that will be listening for the event
{string}event
The name of the event to listen for

(sceneObject,
event)
Register a scene object to listen for all the events with a given name. When an event is triggered, a callback with the same name as the event will be called for this object and all its behaviors (when present). The scene object will receive events that occur outside the bounding boxes of the objects' sprites, where this is applicable (depending on the event type).

Parameters:


{SceneObject}sceneObject
A scene object that will be listening to the event
{string}event
The name of the event to listen for

(path)
Add a Path to the scene

Parameters:


{Path}path
The path to add to the scene

(sceneObject,
autoListen,
params)
Add a scene object to the scene

Parameters:


{SceneObject}sceneObject
The scene object to add to the scene
{boolean}autoListenOptional
This is true by default (if omitted), unless explicitly set to false or a falsy value. When it is true, WADE will set the object to automatically listen for any events for which handlers are defined on the object or any of its behaviors. For example if the object has an onMouseDown function when it's added to the scene (or any of its behaviours has an onMouseDown function) and this parameter is true, the object will be set to listen for onMouseDown events automatically.
paramsOptional
This argument can be any type, is optional, and if present is passed to the onAddToScene event handler(s) for this object

Returns:


{SceneObject}
The scene object that was just added to the scene

(params)
Perform an asynchronous HTTP request

Parameters:


{Object}params
An object with the following fields - only 'url' is mandatory:
  • url: string
  • type: string (either 'GET' or 'POST')
  • cache: boolean (defaults to true - set it to false to ensure you don't get a cached result)
  • dataType: string (set to 'json' to get the response as a JSON object)
  • success: function (a callback to execute when a successful response has been received - the response data is passed to the callback)
  • error: function (a callback to execute if the request fails - any data that was received, such as an incomplete response, is passed to the callback)
()
Check to see if gamepads are supported in the current browser

Returns:


{boolean}
Whether gamepads are supported in the current browsers

(toggle)
Set whether WADE should try to automatically load images that haven't yet been loaded when the app is trying to use them. This happens by default, so you don't need to call autoLoadImages() unless you want to disable the behavior or re-enable it programmatically.

Parameters:


{boolean}toggleOptional
Whether to auto-load images or not. If omitted this is assumed to be true.

(domains)
Do not allow the App to be linked from selected domains

Parameters:


{string|Array}domains
A string (or an array of strings) representing the blacklisted domain(s)

(box1,
box2)
Check whether box1 contains box2

Parameters:


{Object}box1
An object representing a box with the following fields: 'minX', 'minY', 'maxX', 'maxY'
{Object}box2
An object representing a box with the following fields: 'minX', 'minY', 'maxX', 'maxY'

Returns:


{boolean}
Whether box1 contains box2

(box,
point)
Check whether a box contains a point

Parameters:


{Object}box
An object representing a box with the following fields: 'minX', 'minY', 'maxX', 'maxY'
{Object}point
An object with the following fields: 'x', 'y'

Returns:


{boolean}
Whether box contains point

(box1,
box2)
Check whether box1 and box2 intersect each other

Parameters:


{Object}box1
An object representing a box with the following fields: 'minX', 'minY', 'maxX', 'maxY'
{Object}box2
An object representing a box with the following fields: 'minX', 'minY', 'maxX', 'maxY'

Returns:


{boolean}
Whether box1 and box2 intersect each other

(box,
ob)
Check whether an axis-aligned box and an oriented box overlap each other.

Parameters:


{Object}box
An object representing a box with the following fields: 'minX', 'minY', 'maxX', 'maxY'
{Object}ob
An object with 'centerX' and 'centerY' fields representing its center coordinates, and the following fields:
'axisXx' and 'axisXy' represent the rotated X axis (the Width axis) of the rectangle in world-space coordinates. The length of the axisX vector must be half the width of the rectangle.
'axisYx' and 'axisYy' represent the rotated Y axis (the Height axis) of the rectangle in world-space coordinates. The length of the axisY vector must be half the height of the rectangle.

Returns:


{boolean}

(toggle)
Stop the normal input event handling by the browser. Note that this happens by default, so you don't need to call this function unless you want to re-enable the default handling of input events, or change it programmatically.

Parameters:


{boolean}toggleOptional
Whether to cancel the normal handling of event. If this parameter is omitted, it's assumed to be true.

(layerId,
box)
Transform a canvas space box into world space

Parameters:


{number}layerId
The id of the layer to use. This determines the translation and scale factors to use in the transformation.
{Object}box
An object whose 'minX', 'minY', 'maxX' and 'maxY' fields represent a canvas space box

Returns:


{Object}
An object whose 'minX', 'minY', 'maxX' and 'maxY' fields represent a world space box

(layerId,
direction)
Transform a canvas space direction into world space

Parameters:


{number}layerId
The id of the layer to use. This determines the translation and scale factors to use in the transformation.
{Object}direction
An object whose 'x' and 'y' fields represent a canvas space direction

Returns:


{Object}
An object whose 'x' and 'y' fields represent a world space direction

(layerId,
position)
Transform a canvas space position into world space

Parameters:


{number}layerId
The id of the layer to use. This determines the translation and scale factors to use in the transformation.
{Object}position
An object whose 'x' and 'y' fields represent a canvas space position

Returns:


{Object}
An object whose 'x' and 'y' fields represent a world space position

(layerId)
Get the size of a canvas pixel in world-space units

Parameters:


{number}layerId
The id of the layer to use. This determines the translation and scale factors to use in the transformation.

Returns:


{number}
The size of a canvas pixel in world-space units

(box1,
box2)
Resize box1 so that it's fully contained in box2

Parameters:


{Object}box1
An object representing a box with the following fields: 'minX', 'minY', 'maxX', 'maxY'
{Object}box2
An object representing a box with the following fields: 'minX', 'minY', 'maxX', 'maxY'
()
Remove any active timeouts or intervals that have been set via wade.setTimeout() or wade.setInterval()

Returns:


{boolean}
Whether any timeout or interval was active and was removed

(layerId)
Clear the canvas(es) associated with a specific layer. This can be useful when setCanvasClearing(false) has been called for a layer and you want to clear it manually.

Parameters:


{number}layerId
The id of the layer to clear

(intervalUid)
Cancel an interval that was previously scheduled with wade.setInterval()

Parameters:


{number}intervalUid
The unique ID of the interval to cancel.

Returns:


{boolean}
Whether an active interval with the specified ID was found and removed
()
Remove all the scene objects from the scene

()
Stop and delete all timelines


(timeoutUid)
Cancel a timeout that was previously scheduled with wade.setTimeout()

Parameters:


{number}timeoutUid
The unique ID of the timeout to cancel.

Returns:


{boolean}
Whether an active timeout with the specified ID was found and removed

(array)
Clone an array

Parameters:


{Array}array
The array to clone

Returns:


{Array}
A clone of the original array

(object)
Clone an object

Parameters:


{Object}object
The object to clone

Returns:


{Object}
A clone of the original object

(resolutionFactor)
Create an HTML5 canvas object and add it to the document

Parameters:


{number}resolutionFactorOptional
Resolution relative to the the other canvas objects. 1 is full resolution, < 1 is lower resolution, > 1 is higher resolution. Default is 1. How this relates to the number of logical pixels in the canvas depends on the current window mode.

Returns:


{HTMLElement}

(maxLength,
onSet)
Create a pseudo-array, i.e. an object that behaves partly like an array of the specified maxLength, with the ability to execute a function every time an element of the array changes. Note that a pseudo-array only supports the [] operator, the length property and the push function. Other properties of Array are currently not supported.

Parameters:


{number}maxLength
The maximum number of elements in the array
{function}onSet
A function to execute when an element in the array changes. The function will receive 3 arguments: the index of the element, the new value of the element, and a boolean indicating whether this is a new element.

(imageName,
width,
height)
Create a transparent image

Parameters:


{string}imageName
A name that identifies the new image. This can later be used by wade.getImage(imageName) and similar functions, or set as a source image of a Sprite or Animation.
Note that if an image with the same name exists, it will be replaced by the new transparent image.
{number}width
The width of the image in pixels
{number}height
The height of the image in pixels
()
Delete all the canvas objects created by WADE


(layerIds)
Draw a layer, group of layers, or the whole scene. Normally you don't need to do this (WADE does it automatically when needed), but by calling this function you can manuallly control when the drawing happens.

Parameters:


{number|Array}layerIdsOptional
The id of the layer (or layers) to draw. If omitted, the whole scene will be drawn

(layerId,
imageName,
replace,
offset,
transform,
compositeOperation)
Draw a layer to an image in CPU memory

Parameters:


{number}layerId
The id of the layer to use
{string}imageName
The file name (or virtual path) of the target image
{boolean}replaceOptional
Whether to replace the existing image at the virtual path (if it exists), or draw on top of it
{Object}offsetOptional
An object with 'x' and 'y' fields representing the offset to use when drawing this sprite onto the image
{Object}transformOptional
An object with 6 parameters: 'horizontalScale', 'horizontalSkew', 'verticalSkew', 'verticalScale', 'horizontalTranslate', 'verticalTranslate'
{string}compositeOperationOptional
A string describing an HTML5 composite operation

(toggle)
Enable or disable double buffering for the on-screen canvases. When double buffering is enabled, each layer uses two canvases: one is visible, the other is hidden. Whenever a layer needs a full redraw, this is done on the invisible canvas, and when the operation is completed, the two canvases are swapped.

Parameters:


{boolean}toggleOptional
whether to enable or disable double buffering

(toggle)
Enabled or disable gamepad support

Parameters:


{boolean}toggleOptional
Whether to enable or disable gamepad support. If omitted, this parameter is assumed to be true.

(toggle)
Enable or disable support for multi touch. Multi touch is disabled by default.

Parameters:


{boolean}toggleOptional
Whether to enable or disable multi touch. This parameter is true by default.

(data)
A function to log any error message from WADE. By default, this is set to console.error

Parameters:


{*}data
The data to log

(box1,
box2)
Expand box1 so that it encompasses both box1 and box2

Parameters:


{Object}box1
An object representing a box with the following fields: 'minX', 'minY', 'maxX', 'maxY'
{Object}box2
An object representing a box with the following fields: 'minX', 'minY', 'maxX', 'maxY'

(stringify,
exclude,
exportObjectFunctions)
Export the current scene to an object (optionally serializing it to a JSON string), that can then be used to import a scene like the current one, through wade.importScene()

Parameters:


{boolean}stringifyOptional
Whether the result should be serialized to a JSON string
{Array}excludeOptional
An array of scene objects and path (or their names) to exclude from the exported scene
{boolean}exportObjectFunctionsOptional
Whether to export a string representation of all member functions of the scene objects. False by default.

Returns:


{object|string}
Either an object or a JSON string representation of the scene (depending on the serialize parameter)

(layerId,
time,
callback)
Fade in a layer over time

Parameters:


{number}layerId
The id of the layer to fade in
{number}time
How long (in seconds) the fading should take
{function}callbackOptional
A function to execute when the fading is complete

(layerId,
time,
callback)
Fade out a layer over time

Parameters:


{number}layerId
The id of the layer to fade out
{number}time
How long (in seconds) the fading should take
{function}callbackOptional
A function to execute when the fading is complete

(orientation)
Force the app to be displayed in a certain orientation. For example, if the orientation is set to 'landscape', but the screen is taller than it is wide, the app will be rendered rotated by 90 degrees. Forced orientation is disabled by default.

Parameters:


{string}orientationOptional
The orientation to use. This can be 'landscape', 'portrait', or any other string (to disable forced orientation).

(layerId)
Force the full redraw of the scene (or of a single layer)

Parameters:


{number}layerIdOptional
The id of the layer to redraw. If omitted or falsy, all layers will be redrawn.

(sourceImage,
whatToDo,
targetImage)
Apply a per-pixel transformation to an image. Note that you need to load the image (with wade.loadImage) before doing this, or it must be an image that is loaded in memory somehow (it can be an image that you have procedurally generated too).

Parameters:


{string}sourceImage
The file name (or virtual path) of the source image
{function}whatToDo
A function to execute for each pixel. It will receive data about the pixel, and can return an object containing output data. An example is this:
function(r, g, b, a, x, y) { return {r: 255, g: 255, b: 255, a: 255}; }
Where r is red, g is green, b is blue, a is alpha, and x and y are the coordinates of the pixel being processed.
{string}targetImageOptional
The file name (or virtual path) of the target image. If omitted, the source image will be overwritten with the new data.
()
Get a list of the id's of all layers that are currently active (including empty ones)

Returns:


{Array}
An array of layer id's
()
Get the total simulation time, in seconds, since the app was started

Returns:


{number}
The number of seconds the simulation has been running since the app was started
()
Get the base path of the app (i.e. the directory where the main app script is located or the directory that was set via setBasePath)
The result of this function depends on the path that was passed to the last call to wade.init() or wade.setBasePath. It can be an absolute path, or a path relative to the location of WADE.

Returns:


{String}
The base path of the app
()
Get the current camera position.

Returns:


{Object}
An object whose 'x', 'y' and 'z' fields represent the coordinates of the camera position in world space
()
Retrieve the length of the catch-up buffer, that is how many seconds of lag should be tolerated before WADE stops trying to catch up with missed frames

Returns:


{number}
The buffer time, in seconds
()
Get the current system clock time in millisecond. The accuracy will vary depending on the system, an accurate performance timer is used where available.

Returns:


{number}
The current system clock time
()
Get the height of the window that contains the app

Returns:


{number}
The height of the window that contains the app
()
Get the name of the DIV or the HTML element that contains the App. This can be set when calling wade.init.

Returns:


{string}
The name of the container element
()
Get the width of the window that contains the app

Returns:


{number}
The width of the window that contains the app

(file)
Get the base64-encoded dataURL of a font

Parameters:


{string}file
A font dataURL to access (it has to be data that has been set via wade.setFont() first). It can be a relative path, or an absolute path starting with "http://"

Returns:


{string}
The dataURL of the font
()
Checks if the app is being displayed in forced orientation mode.

Returns:


{string}
A string describing the forced orientation. It can be 'landscape', 'portrait', or 'none'

(file)
Get the full path and file name of the specified file. This could be relative to the app's main file location, or an absolute address starting with 'http://', 'https://' or '//'

Parameters:


{string}file
The base file name

Returns:


{string}
The full path and file name

(url)
Get the host name based on a URL string

Parameters:


{string}url
The URL string

Returns:


{string}
The host name

(file,
errorMessage)
Get an image object that has previously been loaded, or a blank image

Parameters:


{string}fileOptional
An image file to get. This must be the file name that was used in a previous call to loadImage, preloadImage or setImage. If omitted or falsy, a bank (white) image is returned
{string}errorMessageOptional
An error message to display in the console if the image hasn't been loaded. If omitted, a default error message will be printed.

Returns:


{Object}
The image object that was requested

(file,
posX,
posY,
width,
height)
Get the raw data of an image file or canvas, as an array of bytes

Parameters:


{string}file
The file name associated with the image or canvas resource
{number}posXOptional
The left coordinate of the data to retrieve. Default is 0.
{number}posYOptional
The top coordinate of the data to retrieve. Default is 0.
{number}widthOptional
The width of the image data to retrieve. By default this is the whole width of the image.
{number}heightOptional
The height of the image data to retrieve. By default this is the whole height of the image.

Returns:


{ImageData}
An HTML ImageData object containing the image data. Use its data property to access the byte array, where pixels are stored sequentially and for each pixel there are 4 bytes representing the red, green, blue and alpha channels in this order.

(imageName)
Generate a data URL from an image that had previously been loaded or procedurally generated

Parameters:


{string}imageName
The name or virtual path of the image

Returns:


{string}
A base64 data URL

(file)


Parameters:


{string}file
A JSON file to access (it has to be a file that has been loaded via wade.loadJson() or set via wade.setJson() first). It can be a relative path, or an absolute path starting with "http://"

Returns:


{object|Array}
The contents of the JSON file

(keyName)
Get the numerical key code associated with a key name, or 0 if the name isn't valid

Parameters:


{string}keyName
The key name

Returns:


{number}
The key code

(keyCode)
Get the key name associated with a numerical key code

Parameters:


{number}keyCode
The key code

Returns:


{string}
The key name

(layerId)
Get the canvas object being used by a layer. You can use it as a source image for sprite and effects.

Parameters:


{number}layerIdOptional
The id of the layer to use. Default is 1

Returns:


{Object}
An HTML5 canvas object

(layerId)
Get the entire set of custom properties of a layer

Parameters:


{number}layerId
The ID of the layer

Returns:


{Object}
An object containing all the custom properties

(layerId,
key)
Retrieve the value of a custom property of a layer

Parameters:


{number}layerId
The ID of the layer
{string}key
The name of the property to set

Returns:


{*}
The value of the property

(layerId)
Generate a data URL from a game layer

Parameters:


{number}layerId
The layer Id

Returns:


{string}
A base64 data URL

(layerId)
Get the opacity of a layer.

Parameters:


{number}layerId
The id of the layer

Returns:


{number}
The opacity of the layer. This is a number between 0 (fully transparent) and 1 (fully opaque)

(layerId)
Get the current render mode of a layer.d

Parameters:


{number}layerId
The id of the layer

Returns:


{string}
The layer render mode. This can be either '2d' or 'webgl'

(layerId)
Get the resolution factor for a specific layer

Parameters:


{number}layerId
The layer id

Returns:


{number}
The resolution factor of the layer

(layerId)
Get the current image smoothing state for a specific layer

Parameters:


layerId
The layer id

Returns:


{boolean}
The image smoothing state for the specified layer

(layerId)
Get the sorting method that is currently being used for the layer

Parameters:


{number}layerId
The layer id

Returns:


{string|function}
A user specified function that was previously set with setLayerSorting, or a string indicating one of the built-in types of sorting: 'bottomToTop', 'topToBottom', 'none'. The default value for a layer sorting method is 'none'.
()
Get the percentage of files that have been fully loaded with respect to the number of files for which a loading operation has been requested

Returns:


{number}
A number between 0 and 100 indicating the percentage of loaded files

(file)
Get the current loading status of a file

Parameters:


{string}file
The file name.

Returns:


{string | undefined}
The loading status: - 'loading' when the loading of the file is in progress - 'ok' if the file was loaded with no problems - 'error' if there were loading errors - 'unknown' if WADE has never been requested to load the file
()
Get the maximum height of the render area

Returns:


{number}
The maximum height of the render area, as set with the last call to setMaxScreenHeight, or 1080 by default
()
Get the maximum width of the render area

Returns:


{number}
The maximum width of the render area, as set with the last call to setMaxScreenWidth, or 1920 by default
()
Get the minimum height of the render area

Returns:


{number}
The minimum height of the render area, as set with the last call to setMinScreenHeight, or 0 by default
()
Get the minimum width of the render area

Returns:


{number}
The minimum width of the render area, as set with the last call to setMinScreenWidth, or 0 by default
()
Get the current mouse position, or the position of the last input event (in the case of touch events). Note that if there have been no mouse or input events since the app started, this will return an empty object

Returns:


{object}
An object with 'x' and 'y' fields describing the screen coordinates of the mouse, or of the last input event

(area,
layerId)
Get the objects inside (or intersecting) the specified area, expressed in world units

Parameters:


{object}area
An object with the following fields (in world-space units): 'minX', 'minY', 'maxX', 'maxY'
{number}layerIdOptional
If specified, the object search will be restricted to this layer id

Returns:


{Array}
An array of scene objects

(area)
Get the objects inside (or intersecting) the specified area, expressed in screen units

Parameters:


{object}area
An object with the following fields (in screen-space units): 'minX', 'minY', 'maxX', 'maxY'

Returns:


{Array}
An array of scene objects

(name)
Get a path, given its name as a string

Parameters:


{string}name

Returns:


{Path}
The Path object with the given name, or null if no path with a matching name is in the scene

(property,
value)
Get a list of all the paths in the scene, or just the paths with a given property/value pair.

Parameters:


{string}propertyOptional
A property that must be set for the paths. Omit this parameter or use a falsy value to get all the paths in the scene.
{*}valueOptional
The value that the property must be set to. You can omit this parameter to get all the paths where the property is defined, regardless of its value

Returns:


{Array}
An array containing references to all the paths that are currently present in the scene

(layerId)
Get the post process shader code being used by a layer

Parameters:


{number}layerId
The ID of the layer

(layerId)
Get the post process shader uniforms being used by a layer

Parameters:


{number}layerId
The ID of the layer

Returns:


{object}
An object whose keys are uniform names and whose values are uniform types

(eventId)
This function can only be used in debug mode to get the details of a timeline event that has been processed. To run WADE in debug mode, set the debug option to true when calling wade.init()

Parameters:


{number}eventIdOptional, Default: 0
The index of the event, e.g. use 0 for the first event that was processed

Returns:


{Object}
An object with a time parameter (a number) and a code parameter (a string)
()
Get the current global resolution factor. Note that resolution factors of individual layers may be different, if they were set through setLayerResolutionFactor

Returns:


{number}
The global resolution factor

(name)
Get a scene object by name. This only works with objects that have been added to the scene.

Parameters:


{string}name
The name of the scene object to look for

Returns:


{SceneObject}
The scene object corresponding to the given name, or null if no SceneObjects have that name

(sceneObject)
Get the current index of a scene object in the scene.

Parameters:


{SceneObject}sceneObject
The SceneObject

Returns:


{number}
The current index of the scene object in the scene

(property,
value)
Get a list of all the objects in the scene, or just the objects with a given property/value pair.

Parameters:


{string}propertyOptional
A property that must be set for the objects. Omit this parameter or use a falsy value to get all the objects in the scene.
{*}valueOptional
The value that the property must be set to. You can omit this parameter to get all the objects where the property is defined, regardless of its value

Returns:


{Array}
An array containing references to all the objects that are currently present in the scene
()
Get the hight of the current render area

Returns:


{number}
The height of the current render area
()
Get the width of the current render area

Returns:


{number}
The width of the current render area

(file)
Get the contents of a script file

Parameters:


{string}file
A script file to access (it has to be a file that has been loaded via wade.loadScript() or set via wade.setScript() first). It can be a relative path, or an absolute path starting with "http://"

Returns:


{string}
The contents of the script file
()
Get the "global" image smoothing state. This is the image smoothing state that is applied to all the layers, unless setLayerSmoothing has been called for some specific layers.

Returns:


{boolean}
The global image smoothing state

(area,
layerId,
sorted)
Get the sprites inside (or intersecting) the specified area, expressed in world units

Parameters:


{object}area
An object with the following fields (in world-space units): 'minX', 'minY', 'maxX', 'maxY'
{number}layerIdOptional
If specified, the sprite search will be restricted to this layer id
{boolean}sortedOptional
If set to true or a truthy value, the resulting array will be sorted according to the layer number and each layer's sort function

Returns:


{Array}
An array of sprites

(area)
Get the sprites inside (or intersecting) the specified area, expressed in screen units

Parameters:


{object}area
An object with the following fields (in screen-space units): 'minX', 'minY', 'maxX', 'maxY'

Returns:


{Array}
An array of sprites

(file)


Parameters:


{string}file
A text file to access (it has to be a file that has been loaded via wade.loadText() or set via wade.setText() first). It can be a relative path, or an absolute path starting with "http://"

Returns:


{string}
The contents of the text file
()
Get a reference to all the timelines, active and inactive. You can check the active flag on each timeline to check its status.

()
Get the current version of WADE as a string. If you are using it to make sure that it's greater than a certain version, you may want to use wade.requireVersion instead.

Returns:


{string}
The current version of WADE.
()
If WebAudio is supported, get the current WebAudio context

Returns:


{AudioContext}
The current WebAudio context. If WebAudio is not supported, this function returns undefined.
()
Get the current window mode.

Returns:


{string}
The current window mode.

(str)
Get a 32-bit integer hash of a given string

Parameters:


{string}str
The string to hash

Returns:


{number}
The hash of the input string

(data,
loadingBar,
callback,
async,
clearScene)
Import a scene from an object that contains a description of all the entities in the scene - it could have been previously exported with wade.exportScene(), or edited manually. This will automatically load all the assets referenced in the scene data.

Parameters:


{object}data
A scene description object, such as one created with wade.exportScene(). The format is the following (all fields are optional):
    {
  • json: An array of file names, describing which json files should be loaded. This can also be an array of objects in the format {resource: string, target: string} where resource is the file to load, and the result is stored in wade.app[target].
  • text: An array of file names, describing which text files should be loaded. This can also be an array of objects in the format {resource: string, target: string} where resource is the file to load, and the result is stored in wade.app[target].
  • audio: An array of audio file names
  • scripts: An array of script (.js) file names. Note that these scripts will be loaded and executed after the rest of the scene has been loaded, but before any scene objects are created and added to the scene
  • images: An array of image file names - you don't need to include files that are referenced by the scene objects and sprites in the scene (those will be loaded automatically).
  • minScreenSize: An object with x and y components describing the minimum screen size. Refer to the documentation of wade.setMinScreenSize() for more details
  • maxScreenSize: An object with x and y components describing the maximum screen size. Refer to the documentation of wade.setMaxScreenSize() for more details
  • windowMode: A string describing the window mode. Refer to the documentation of wade.setWindowMode() for more details
  • orientation: A string describing the orientation. Valid values are 'portrait' and 'landscape', all other values are ignored. See wade.forceOrientation() for more details
  • sceneObjects: An array containing all the SceneObjects to instantiate. See the SceneObject documentation for more details about the format to use
  • modules: An object where the name of each property is the name of an external WADE module whose importScene is called to load the scene data described by the value of that property
  • webAudioOnly: A boolean describing whether audio should only be loaded through WebAudio, and only where WebAudio is supported
  • loadGlTextures: A boolean describing whether WebGl textures should be created at loading time (only applies to sprites that are on WebGl layers)
  • }
{{position: {x: number|y: number}|foreColor: string|backColor: string}}loadingBarOptional
A loading bar while loading the assets referenced in the scene data (see wade.setLoadingBar for details about the parameters, which are all optional). If omitted or falsy, no loading bar will be shown
{function}callbackOptional
A function to execute when the scene has been imported
{boolean}asyncOptional
Whether the scene should be loaded asynchronously in the background, without blocking the simulation and rendering of the app. False by default
{boolean}clearSceneOptional
Whether the current scene should be cleared before adding objects for the new scene. False by default

(appScript,
appData,
options)
Initialize the engine

Parameters:


{string}appScript
Path and filename of the main app script
{Object}appDataOptional, Default: {}
An object containing initialization data for the app
{Object}optionsOptional, Default: {}
An object that contains a set of fields that specify some configuration options. All the fields are optional. Supported values are:
  • forceReload: boolean - Whether to force reloading the main app script (as opposed to trying to get it from the cache. Defaults to false
  • updateCallback: function - A function to execute when an update for the cached version of the app is available and has been downloaded. This only applies to apps using the application cache. If omitted, the default behavior is to display an alert, after which the page will be refreshed.
  • container: string - The name of an HTML element in the current document (typically a DIV), that will contain all of the app's canvases and will be used to detect input events. Default is 'wade_main_div'.
  • debug: boolean - Whether to run the app in debug mode. When this is active, the source code of functions loaded through scene files will be easily accessible from the debugger. This will also inject 'sourceURL' tags into all dynamically loaded scripts. Defaults to false.
  • audio: boolean - Whether to activate audio or not. Defaults to true.
  • input: boolean - Whether to activate input or not. Defaults to true.
  • forceWebGl: boolean - Whether to use WebGl even when the browser detects potential performance problems. Defaults to false.
  • globalUnderscore: boolean - Whether to use the global _ variable to access scene objects. Defaults to true.
  • ()
    Initialize the user app. This function is called automatically when the main app is finished loading its assets.

    ()
    Create an instance of the user app. This function is called automatically when the main app script is finished loading.

    ()
    Checks whether the init function for the app has been executed


    (a)
    Check whether an object is an Array

    Parameters:


    {object}a
    The object to test

    Returns:


    {boolean}
    Whether the object is a JavaScript Array
    ()
    Check whether WADE is automatically trying to load images that haven't yet been loaded when the app is trying to use them.

    Returns:


    {boolean}
    The status of the auto-load behavior.
    ()
    Check whether we are currently running in debug mode

    Returns:


    {boolean}
    Whether we are currently running in debug mode
    ()
    Check the current state of double buffering. When double buffering is enabled, each layer uses two canvases: one is visible, the other is hidden. Whenever a layer needs a full redraw, this is done on the invisible canvas, and when the operation is completed, the two canvases are swapped.

    Returns:


    {boolean}
    The current state of double buffering

    (sceneObject,
    event)
    Check to see if a Scene Object is currently listening for a specific type of event

    Parameters:


    {SceneObject}sceneObject
    The scene object to check
    {string}event
    The name of the event

    Returns:


    {boolean}
    Whether the scene object is currently listening for the event

    (keyCode)
    Check whether a key is currently down (it's being pressed by the user).

    Parameters:


    keyCode
    The code of the key to check

    Returns:


    {boolean}
    Whether the key is pressed

    (buttonId)
    Check whether a mouse button is currently pressed. For touch-screen devices, the return value represents whether the screen is being touched

    Parameters:


    {number}buttonIdOptional
    Which mouse button to check (0 for left, 1 for middle, 2 for right). If omitted, the function returns true if any mouse button (or touch pointer) is pressed.

    Returns:


    {boolean}
    Whether a mouse button is pressed
    ()
    Check whether multi touch support is current enabled. By default it's disabled, unless you call wade.enableMultitouch()

    ()
    Checks whether the screen is rotated, with respect to the orientation that was set with forceOrientation(). For example, this returns true if forceOrientation() was called to set a 'landscape' orientation, and now the screen is taller than it is wide (therefore the screen appears rotated by 90 degrees to the viewer).

    Returns:


    {boolean}

    (layerId)
    Check whether a layer is using quadtree-based optimizations

    Parameters:


    {number}layerId
    The id of the layer to check

    Returns:


    {boolean}
    Whether the layer is using a quadtree
    ()
    Checks whether the WebAudio API is supported by the client

    Returns:


    {boolean}
    whether the WebAudio API is supported
    ()
    Check to see if WebGL is supported

    Returns:


    {boolean}
    Whether WebGL is supported in the current environment

    (file,
    autoplay,
    looping,
    callback,
    errorCallback)
    Load an audio file. Although the loading happens asynchronously, the simulation is suspended until this operation is completed.
    If a loading screen has ben set, it will be shown during the loading.
    See preloadAudio for an equivalent operation that happens in the background without suspending the simulation.

    Parameters:


    {string}file
    The audio file to load. Note that while some browsers support '.aac' files, some don't and support '.ogg' instead. If you plan to use one of these formats, you should provide the same file in the other format too in the same location (same file name but different extension). It then doesn't matter wheter you refer to your file as 'fileName.aac' or 'fileName.ogg', because WADE will automatically use the one that is supported by the client
    {boolean}autoplayOptional
    Whether to start play the audio file as soon as it's ready.
    {boolean}loopingOptional
    Whether to repeat the audio when it's over
    {function}callbackOptional
    A function to execute when the audio is ready to play
    {function}errorCallbackOptional
    A callback to execute when the audio file cannot be loaded

    (file,
    callback,
    errorCallback)
    Load a font file. Although the loading happens asynchronously, the simulation is suspended until this operation is completed.
    If a loading screen has ben set, it will be shown during the loading.
    See preloadFont for an equivalent operation that happens in the background without suspending the simulation.

    Parameters:


    {string}file
    A fonr file to load (.woff files are universally supported, other format may be supported depending on the browser). It can be a relative path, or an absolute path starting with "http://" or "https://" or "//"
    {function}callbackOptional
    A callback to execute when the file is loaded
    {function}errorCallbackOptional
    A callback to execute when the font cannot be loaded

    (file,
    callback,
    errorCallback)
    Load an image file. Although the loading happens asynchronously, the simulation is suspended until this operation is completed.
    If a loading screen has ben set, it will be shown during the loading.
    See preloadImage for an equivalent operation that happens in the background without suspending the simulation.

    Parameters:


    {string}file
    An image file to load. It can be a relative path, or an absolute path starting with "http://"
    {function}callbackOptional
    A callback to execute when the file is loaded
    {function}errorCallbackOptional
    A callback to execute when the image cannot be loaded

    (arrayOfFileNames)
    This is a helper functions to load multiple images in a single function call, and is equivalent to calling wade.loadImage() multiple times.

    Parameters:


    {Array}arrayOfFileNames
    An array of strings, where each string is the file name of an image to load.

    (file,
    objectToStoreData,
    callback,
    forceReload,
    errorCallback)
    Load a JavaScript Object Notation (JSON) data file. Although the loading happens asynchronously, the simulation is suspended until this operation is completed.
    If a loading screen has ben set, it will be shown during the loading.
    See preloadJson for an equivalent operation that happens in the background without suspending the simulation.

    Parameters:


    {string}file
    A json file to load. It can be a relative path, or an absolute path starting with "http://"
    {Object}objectToStoreDataOptional
    An object that will be used to store the data. When the loading is complete, objectToStoreData.data will contain the contents of the json file
    {function}callbackOptional
    A callback to execute when the script is loaded
    {boolean}forceReloadOptional
    Whether to force the client to reload the file even when it's present in its cache#
    {function}errorCallbackOptional
    A callback to execute when the json file cannot be loaded

    (url)
    Open a web page in the app's window.

    Parameters:


    {string}url
    The address of the web page to open

    (fileName,
    loadingBar,
    callback,
    clearScene)
    Load a JSON file that contains the description of a wade scene, and process that file to load any assets being used and instantiate SceneObjects, Sprites, TextSprites and Animations according to the scene description. This is the same as wade.preloadScene(), except that the loading happens synchronously, blocking the rendering and simulation of the current scene

    Parameters:


    {string}fileName
    The name of a JSON file containing a description of the scene
    {{position: {x: number|y: number}|foreColor: string|backColor: string}}loadingBarOptional
    A loading bar while loading the assets referenced in the scene data (see wade.setLoadingBar for details about the parameters, which are all optional). If omitted or falsy, no loading bar will be shown
    {function}callbackOptional
    A function to execute when the scene has been loaded
    {boolean}clearSceneOptional
    Whether the previous scene should be cleared before adding objects for the new scene. False by default

    (file,
    callback,
    forceReload,
    errorCallback,
    dontExecute)
    Load a javascript file. Although the loading happens asynchronously, the simulation is suspended until this operation is completed.
    If a loading screen has ben set, it will be shown during the loading.
    See preloadScript for an equivalent operation that happens in the background without suspending the simulation.

    Parameters:


    {string}file
    A javascript file to load. It can be a relative path, or an absolute path starting with "http://"
    {function}callbackOptional
    A callback to execute when the script is loaded
    {boolean}forceReloadOptional
    Wheter to force the client to reload the file even when it's present in its cache
    {function}errorCallbackOptional
    A callback to execute when the script cannot be loaded
    {boolean}dontExecuteOptional
    Scripts loaded via wade.loadScript() are automatically executed. Set this boolean to true to avoid executing them as they are loaded.

    (file,
    objectToStoreData,
    callback,
    forceReload,
    errorCallback)
    Load a plain text file. Although the loading happens asynchronously, the simulation is suspended until this operation is completed.
    If a loading screen has ben set, it will be shown during the loading.
    See preloadText for an equivalent operation that happens in the background without suspending the simulation.

    Parameters:


    {string}file
    A text file to load. It can be a relative path, or an absolute path starting with "http://"
    {Object}objectToStoreDataOptional
    An object that will be used to store the data. When the loading is complete, objectToStoreData.data will contain the contents of the text file
    {function}callbackOptional
    A callback to execute when the script is loaded
    {boolean}forceReloadOptional
    Whether to force the client to reload the file even when it's present in its cache#
    {function}errorCallbackOptional
    A callback to execute when the text file cannot be loaded

    (data)
    A function to log any message from WADE. By default, this is set to console.log

    Parameters:


    {*}data
    The data to log

    (destination,
    speed,
    callback)
    Gradually move the camera to the specified position, with the specified speed. If wade.app.onCameraMoveComplete exists, it's executed when the camera finishes moving. If you need to change the camera position instantly, use setCameraPosition() instead.

    Parameters:


    {object}destination
    The destination of the camera. This is an object with 'x', 'y' and 'z' fields, where 'z' is depth (or distance from the scene), and is 1 by default.
    {number|function}speedOptional
    The movement speed. This can be a number, or a function of distance that returns a number
    {function}callbackOptional
    A function to execute when the camera is finished moving. Using this callback is the same as defining an App.onCameraMoveComplete function, which would be called when the camera is finished moving.

    (ob,
    point)
    Check whether an oriented box contains a point

    Parameters:


    {Object}ob
    An object with 'centerX' and 'centerY' fields representing its center coordinates, and the following fields:
    'axisXx' and 'axisXy' represent the rotated X axis (the Width axis) of the rectangle in world-space coordinates. The length of the axisX vector must be half the width of the rectangle.
    'axisYx' and 'axisYy' represent the rotated Y axis (the Height axis) of the rectangle in world-space coordinates. The length of the axisY vector must be half the height of the rectangle.
    {Object}point
    An object with the following fields: 'x', 'y'

    Returns:


    {boolean}
    Whether orientedBox contains point

    (box,
    ob)
    Check whether an axis-aligned box and an oriented box overlap each other.

    Parameters:


    {Object}box
    An object representing a box with the following fields: 'minX', 'minY', 'maxX', 'maxY'
    {Object}ob
    An object with 'centerX' and 'centerY' fields representing its center coordinates, and the following fields:
    'axisXx' and 'axisXy' represent the rotated X axis (the Width axis) of the rectangle in world-space coordinates. The length of the axisX vector must be half the width of the rectangle.
    'axisYx' and 'axisYy' represent the rotated Y axis (the Height axis) of the rectangle in world-space coordinates. The length of the axisY vector must be half the height of the rectangle.

    Returns:


    {boolean}

    (ob1,
    ob2)
    Check whether two oriented boxes intersect each other. Each box must be an object with 'centerX' and 'centerY' fields representing its center coordinates, and the following fields:
    'axisXx' and 'axisXy' represent the rotated X axis (the Width axis) of the rectangle in world-space coordinates. The length of the axisX vector must be half the width of the rectangle.
    'axisYx' and 'axisYy' represent the rotated Y axis (the Height axis) of the rectangle in world-space coordinates. The length of the axisY vector must be half the height of the rectangle.

    Parameters:


    {Object}ob1
    An oriented box
    {Object}ob2
    The other oriented box

    Returns:


    {boolean}
    Whether the two boxes intersect each other

    (mainLoopName)
    Pause the simulation

    Parameters:


    {string}mainLoopNameOptional
    The name of the main loop that you want to pause. If omitted, the whole simulation will be paused.

    (file,
    looping,
    callback)
    Play an audio file that has previously been loaded with a call to loadAudio or preloadAudio

    Parameters:


    {string}file
    The file name for the audio object. This must be the same string that was used in a previous call to loadAudio or preloadAudio
    {boolean}looping
    Whether to repeat the audio when it's over
    {function}callbackOptional
    A function to call when the sound is finished playing

    Returns:


    {number}
    a unique identifier of the audio source that is being played. A value of -1 indicates that there has been an error, e.g. the audio file was not loaded and ready to play

    (file,
    start,
    end,
    callback)
    Play a segment of an audio file

    Parameters:


    {string}file
    The file name for the audio object. This must be the same string that was used in a previous call to loadAudio or preloadAudio
    {number}startOptional
    The starting point, in seconds. If omitted or falsy, the sound will be played from the beginning
    {number}endOptional
    The ending point, in seconds. If omitted or falsy, the sound is played from the start position to the end of the source file.
    {function}callbackOptional
    A function to call when the ending point is reached

    Returns:


    {number}
    a unique identifier of the audio source that is being played. A value of -1 indicates that there has been an error, e.g. the audio file was not loaded and ready to play

    (url,
    object,
    callback,
    extraParameters)
    Send an object to a server. The object is serialized to JSON before being sent.

    Parameters:


    {string}url
    The web address to send the object to
    {Object}object
    A javascript object to send
    {function}callback
    A function to call when the server replies
    {Object}extraParameters
    An object containing extra parameters to send together with the object (for example a cookie for csrf prevention)

    (file,
    autoplay,
    looping,
    callback,
    errorCallback)
    Load an audio file asynchronously, without suspending the simulation.

    Parameters:


    {string}file
    The audio file to load. Note that while some browsers support '.aac' files, some don't and support '.ogg' instead. If you plan to use one of these formats, you should provide the same file in the other format too in the same location (same file name but different extension). It then doesn't matter wheter you refer to your file as 'fileName.aac' or 'fileName.ogg', because WADE will internally use the one that is supported by the client
    {boolean}autoplayOptional
    Whether to start play the audio file as soon as it's ready.
    {boolean}loopingOptional
    Whether to repeat the audio when it's over
    {function}callbackOptional
    A function to execute when the audio is ready to play
    {function}errorCallbackOptional
    A callback to execute when the audio file cannot be loaded

    (file,
    callback,
    errorCallback)
    Load a font file asynchronously, without suspending the simulation.

    Parameters:


    {string}file
    A font file to load (.woff files are universally supported, other format may be supported depending on the browser). It can be a relative path, or an absolute path starting with "http://" or "https://" or "//"
    {function}callbackOptional
    A callback to execute when the file is loaded
    {function}errorCallbackOptional
    A callback to execute when the font cannot be loaded

    (file,
    callback,
    errorCallback)
    Load an image file asynchronously, without suspending the simulation.

    Parameters:


    {string}file
    An image file to load. It can be a relative path, or an absolute path starting with "http://"
    {function}callbackOptional
    A callback to execute when the file is loaded
    {function}errorCallbackOptional
    A callback to execute when the image cannot be loaded

    (file,
    objectToStoreData,
    callback,
    forceReload,
    errorCallback)
    Load a JavaScript Object Notation (JSON) data file asynchronously, without suspending the simulation.

    Parameters:


    {string}file
    A json file to load. It can be a relative path, or an absolute path starting with "http://"
    {Object}objectToStoreDataOptional
    An object that will be used to store the data. When the loading is complete, objectToStoreData.data will contain the contents of the json file
    {function}callbackOptional
    A callback to execute when the script is loaded
    {boolean}forceReloadOptional
    Whether to force the client to reload the file even when it's present in its cache
    {function}errorCallbackOptional
    A callback to execute when the json file cannot be loaded

    (fileName,
    loadingBar,
    callback,
    clearScene)
    Load a JSON file that contains the description of a wade scene, and process that file to load any assets being used and instantiate SceneObjects, Sprites, TextSprites and Animations according to the scene description. This is the same as wade.loadScene(), except that the loading happens asynchronously without blocking the rendering and simulation of the current scene

    Parameters:


    {string}fileName
    The name of a JSON file containing a description of the scene
    {{position: {x: number|y: number}|foreColor: string|backColor: string}}loadingBarOptional
    A loading bar while loading the assets referenced in the scene data (see wade.setLoadingBar for details about the parameters, which are all optional). If omitted or falsy, no loading bar will be shown
    {function}callbackOptional
    A function to execute when the scene has been loaded
    {boolean}clearSceneOptional
    Whether the previous scene should be cleared before adding objects for the new scene. False by default

    (file,
    callback,
    forceReload,
    errorCallback,
    dontExecute)
    Load a javascript file asynchronously, without suspending the simulation.

    Parameters:


    {string}file
    A javascript file to load. It can be a relative path, or an absolute path starting with "http://"
    {function}callbackOptional
    A callback to execute when the script is loaded
    {boolean}forceReloadOptional
    Wheter to force the client to reload the file even when it's present in its cache
    {function}errorCallbackOptional
    A callback to execute when the script cannot be loaded
    {boolean}dontExecuteOptional
    Scripts loaded via wade.preloadScript() are automatically executed. Set this boolean to true to avoid executing them as they are loaded.

    (file,
    objectToStoreData,
    callback,
    forceReload,
    errorCallback)
    Load a plain text file asynchronously, without suspending the simulation.

    Parameters:


    {string}file
    A text file to load. It can be a relative path, or an absolute path starting with "http://"
    {Object}objectToStoreDataOptional
    An object that will be used to store the data. When the loading is complete, objectToStoreData.data will contain the contents of the text file
    {function}callbackOptional
    A callback to execute when the script is loaded
    {boolean}forceReloadOptional
    Whether to force the client to reload the file even when it's present in its cache
    {function}errorCallbackOptional
    A callback to execute when the text file cannot be loaded
    ()
    Prevent the WADE App from being executed inside an iframe


    (event,
    eventData)
    Process a given event. A callback function with the same name as the event will be called for the objects that have been registered with addEventListener for this event.
    Note that when a listener indicates that they have processed the event (by returning true in their callback), the event won't be passed to any more listeners.

    Parameters:


    {string}event
    The name of the event to process
    {Object}eventDataOptional
    An object to be passed to all the callbacks that will be called

    Returns:


    {boolean}
    Whether any listener succesfully processed the event

    (file,
    data,
    destX,
    destY,
    sourceX,
    sourceY,
    width,
    height)
    Write raw data into an image or canvas resource. Best used in conjunctions with wade.getImageData()

    Parameters:


    {string}file
    The file name associated with the image or canvas resource to modify. If a resource associated with this file name doesn't exist, it will be created and its dimensions will be set to the specified width and height, or to the image data's width and height if the widht and height parameters aren't set explicitly.
    {ImageData}data
    A HTML ImageData object containing the raw data
    {number}destXOptional
    The left coordinate of the destination image (where the data is going to copied). Default is 0.
    {number}destYOptional
    The top coordinate of the destination image (where the data is going to copied). Default is 0.
    {number}sourceXOptional
    The left coordinate of the source data to copy. Default is 0.
    {number}sourceYOptional
    The top coordinate of the source data to copy. Default is 0.
    {number}widthOptional
    The width of the data to copy. By default this is the whole width of the source image data.
    {number}heightOptional
    The height of the data to copy. By default this is the whole height of the source image data.
    ()
    Recreate canvas objects that were delete with a call to wade.deleteCanvases


    (sceneObject,
    event)
    Unregister an object that has previously been registered to listen for an event using addEventListener.

    Parameters:


    {SceneObject}sceneObject
    The scene object to unregister
    {string}event
    The name of the event to stop listening for

    (sceneObject,
    event)
    Unregister an object that has previously been registered to listen for an event using addGlobalEventListener.

    Parameters:


    {SceneObject}sceneObject
    The scene object to unregister
    {string}event
    The name of the event to stop listenening for

    (layerId)
    Remove a layer that was previously created, and free all the associated resources

    Parameters:


    {number}layerId
    The id of the layer to remove

    (object,
    array)
    Remove an object from an array

    Parameters:


    {Object}object
    The object to remove from the array
    {Array}array
    The array that contains the object

    Returns:


    {Object}
    The array after the object has been removed

    (index,
    array)
    Remove an object from an array based on the object's index into the array

    Parameters:


    {number}index
    The index of the object to remove
    {Array}array
    The array that contains the object

    Returns:


    {Object}
    The array after the object has been removed

    (path)
    Remove a Path from the scene

    Parameters:


    {Path|string}path
    The path to be removed from the scene, or its name as a string

    (sceneObject)
    Remove a scene object from the scene

    Parameters:


    {SceneObject|string}sceneObject
    The object to remove from the scene. If the scene object that you want to remove has a name, you can use its name (a string) rather than a reference to the object itself.

    (sceneObjects)
    Remove multiple scene objects from the scene

    Parameters:


    {Array}sceneObjects
    An array of scene objects to remove from the scene

    (exceptions)
    Remove all layers that contain no sprites, and release all the associated resources

    Parameters:


    {Array}exceptionsOptional
    An array of layer id's that you do NOT want to remove even if unused

    (requiredVersion,
    errorMode,
    errorMessage)
    Ensure that the current version of WADE is greater or equal than a specific version.

    Parameters:


    {string}requiredVersion
    The required version of WADE. For example '1.0.2'
    {string}errorModeOptional
    The type of error message to display. This can be 'alert' to show an alert box, 'console' to print a message in the console, or anything else to not show an error message
    {string}errorMessageOptional
    The error message to display. Default is 'A newer version of WADE is required;.
    ()
    Restart listening to input events after a call to wade.stopInputEvents()


    (mainLoopName)
    Resume the simulation (typically after it was paused via wade.pauseSimulation)

    Parameters:


    {string}mainLoopNameOptional
    The name of the main loop that you want to resume. If omitted, the whole simulation will be resumed.

    (timelineId)
    Resume an inactive timeline

    Parameters:


    {string}timelineId
    The ID of the timeline, as obtained by a previous call to wade.startTimeline()

    (name)
    Retrieve an object from the local storage, that has previously been saved through storeLocalObject()

    Parameters:


    {string}name
    The name of the object to retrieve

    (flowChartData,
    startNode,
    precompile,
    delay,
    parentObject)
    Execute a flow chart

    Parameters:


    {object}flowChartData
    This is an object that contains a set of boxes. Each property of this object is the unique id of a box. Each box is itself an object with the following properties:
    • uid: string - a unique identifier for the box
    • children: object - an object where each property name represents a condition, and each property value is the uid of another box in the chart
    • title: string
    • code: string - the code to execute for the box. This code can call this.next(condition) to advance to the next box. It is possible to call this.next() without arguments to simply go to the first child in the list of children. Note that moving from one box to the next is an asynchronous process.
    • startNode: boolean
    • Whether this is a starting node
    {string}startNodeOptional
    The title or the uid of the starting box. If omitted or null, the entire data is scanned to find a box with the startNode flag. When that fails, the first box is used as a start node.
    {boolean}precompileOptional
    Whether the code for all boxes should be compiled when runFlowChart is called, as opposed to compiling each function as it is needed. This is true by default.
    {number}delayOptional, Default: 0
    How many milliseconds to wait when moving from one box to the next
    {SceneObject}parentObjectOptional
    The owner of the flow chart. This determines the context (i.e. the meaning of the this keyword) for the flow chart functions.

    Returns:


    {object}
    An object that contains data about the current state of the flow chart, as follows: startTime: number - when the flow chart was executed. This is a number in seconds relative to the starting point of the wade app flowChartData: object - a copy of the data that is passed in as the first argument to this function visitedNodes: array - a list of the uid's of all the nodes that have been visited so far running: boolean - whether the flow chart is still executing

    (layerId,
    box)
    Transform a screen space box into world space

    Parameters:


    {number}layerId
    The id of the layer to use. This determines the translation and scale factors to use in the transformation.
    {Object}box
    An object whose 'minX', 'minY', 'maxX' and 'maxY' fields represent a screen space box

    Returns:


    {Object}
    An object whose 'minX', 'minY', 'maxX' and 'maxY' fields represent a world space box

    (imageName)
    Draw the contents of the WADE screen to an image in CPU memory

    Parameters:


    {string}imageName
    The file name (or virtual path) of the target image

    (layerId,
    direction)
    Transform a screen space direction into world space

    Parameters:


    {number}layerId
    The id of the layer to use. This determines the translation and scale factors to use in the transformation.
    {Object}direction
    An object whose 'x' and 'y' fields represent a screen space direction

    Returns:


    {Object}
    An object whose 'x' and 'y' fields represent a world space direction

    (layerId,
    position)
    Transform a screen space position into world space

    Parameters:


    {number}layerId
    The id of the layer to use. This determines the translation and scale factors to use in the transformation.
    {Object}position
    An object whose 'x' and 'y' fields represent a screen space position

    Returns:


    {Object}
    An object whose 'x' and 'y' fields represent a world space position

    (layerId)
    Get the size of a screen pixel in world-space units

    Parameters:


    {number}layerId
    The id of the layer to use. This determines the translation and scale factors to use in the transformation.

    Returns:


    {number}
    The size of a screen pixel in world-space units

    (interval)
    Set a custom interval for the 'onAppTimer' event. If this function is never called, the interval is 1 second by default.

    Parameters:


    {number}interval
    The number of seconds between 'onAppTimer' events

    (file,
    audio,
    callback,
    setForPreloader)
    Associate a file name with an audio object, so that any subsequent calls to getAudio using the given file name will return that object.

    Parameters:


    {string}file
    The audio file name
    {Object}audioOptional
    The audio object
    {function}callbackOptional
    A function to execute when the audio has finished decoding and is fully set. This is useful if the audio object is a data URI of a compressed audio type that needs to be decoded
    {boolean}setForPreloaderOptional
    Whether to apply this operation to the asset preloader as well as the asset loader. This is false by default. If set to true, subsequent calls to wade.preloadAudio will get this cached version of the data instead of loading it again in the background.

    (path)
    Set the base path of the app. Omit the parameter or set it to an empty string "" if you want to always use absolute paths

    Parameters:


    {String}path
    the base path of the app

    (pos)
    Set a world space position for the camera.

    Parameters:


    {Object}pos
    An object whose 'x', 'y' and 'z' fields represent the coordinates of the camera position in world space

    (target,
    inertia,
    offset)
    Set a scene object for the camera to follow.

    Parameters:


    {SceneObject}targetOptional
    The scene object to follow. If omitted or falsy, the camera target is cleared.
    {number}inertiaOptional
    The inertia of the camera, between 0 (no inertia) and 1 (maximum inertia, i.e. the camera doesn't move at all)
    {object}offsetOptional
    An object with 'x' and 'y' fields, that specifies an offset relative to the center of the target scene object to follow.

    (layerId,
    toggle)
    Determine whether the canvas (or the portions of it that have changed) should be cleared between frames. This happens by default but, where possible, you may want to disable the clearing to improve performance.

    Parameters:


    {number}layerId
    The layer id
    {boolean}toggle
    Whether to clear the canvas between frames

    (bufferTime)
    Set how many seconds of lag should be tolerated before WADE stop trying to catch up with missed frames

    Parameters:


    {number}bufferTime
    The buffer time, in seconds

    (tolerance)
    Set a tolerance for "onClick" events. A click is defined as a mouseDown followed by a mouseUp in the same place. However, especially in a touch-screen environment, it is possible (and indeed frequent) that the two events occur in slightly different places. Use this function to define the tolerance that you want for click events - default is 5.

    Parameters:


    {number}toleranceOptional
    The tolerance for "onClick" events, in pixels.

    (file,
    data,
    setForPreloader)
    Associate a file name with a font, so that any subsequent calls to getFont using the given file name will return that font.

    Parameters:


    {string}file
    The font file name
    {string}dataOptional
    The dataURL of the font
    {boolean}setForPreloaderOptional
    Whether to apply this operation to the asset preloader as well as the asset loader. This is false by default. If set to true, subsequent calls to wade.preloadFont will get this cached version of the data instead of loading it again in the background.

    (toggle)
    Toggle full screen mode. Note that not all browsers support this, so it may fail. Also, call this from an onMouseUp or onClick event to increase the chances of success.

    Parameters:


    {boolean}toggleOptional
    Whether to enable or disable full screen mode. If not specified, "true" is assumed.

    (callback)
    Set a callback to be executed when all the pending loading requests terminate. Note that preloading requests are ignored for this purpose.

    Parameters:


    {function}callback
    A callback to be executed when all the pending loading requests terminate

    (file,
    image,
    setForPreloader)
    Associate a file name with an image object, so that any subsequent calls to getImage using the given file name will return that object.

    Parameters:


    {string}file
    The image file name
    {Object}imageOptional
    The image object
    {boolean}setForPreloaderOptional
    Whether to apply this operation to the asset preloader as well as the asset loader. This is false by default. If set to true, subsequent calls to wade.preloadImage will get this cached version of the data instead of loading it again in the background.

    (f,
    time)
    Schedule the periodic execution of a function. This is similar to JavaScript's native setInterval function, but it depends on the app simulation time (that can be paused programmatically or when the app is running in a background tab) rather than the actual clock time.

    Parameters:


    {function}f
    A function to execute periodically
    {number}time
    The app simulation time, in milliseconds, to wait between function calls

    Returns:


    {number}
    A unique ID that can be used to cancel the interval via wade.clearInterval()

    (file,
    data,
    setForPreloader)
    Associate a file name with a JSON object, so that any subsequent calls to getJson using the given file name will return that object.

    Parameters:


    {string}file
    The JSON file name
    {Object}dataOptional
    The data object to associate with the JSON file name
    {boolean}setForPreloaderOptional
    Whether to apply this operation to the asset preloader as well as the asset loader. This is false by default. If set to true, subsequent calls to wade.preloadJson will get this cached version of the data instead of loading it again in the background.

    (layerId,
    transformString,
    transformOrigin,
    time,
    callback)
    Set a CSS 3D transform on a layer. See this MDN article for more details.

    Parameters:


    {number}layerId
    The id of the layer
    {string}transformStringOptional
    Any valid CSS 3D transform string. Omitting this parameter resets the transform
    {string}transformOriginOptional
    Any valid CSS 3D transform-origin string. Omitting this parameter resets the transform origin to (50% 50%)
    {number}timeOptional
    The time (in seconds) needed for the transform to be applied. Omitting this parameter or setting it to 0 results in the transform to be applied instanty. Any other number will result in the transform being applied smoothly over the specified period of time
    {function}callbackOptional
    A function to execute when the transform has been applied

    (layerId,
    properties)
    Set a set of custom properties for a layer. This is mainly useful to set the values of shader uniforms used in custom post-process shaders. Note that, unlike wade.setLayerCustomProperty(), this will completely remove any existing custom properties from the layer before setting the new ones.

    Parameters:


    layerId
    properties

    (layerId,
    key,
    value)
    Set a custom property for a layer. This is mainly useful to set the values of shader uniforms used in custom post-process shaders.

    Parameters:


    {number}layerId
    The ID of the layer
    {string}key
    The name of the property to set
    {*}valueOptional
    The value of the property

    (layerId,
    opacity)
    Set the opacity of a layer. This is then applied to the layer canvas(es) via CSS.

    Parameters:


    {number}layerId
    The id of the layer
    {number}opacity
    The opacity of the layer, between 0 (fully transparent) and 1 (fully opaque)

    (layerId,
    renderMode,
    options)
    Set the render mode for a layer

    Parameters:


    {number}layerId
    The id of the layer
    {string}renderMode
    The render mode for the layer. This can be either '2d' or 'webgl'. On devices that don't support webgl, setting the render mode to 'webgl' won't have any effect.
    {object}optionsOptional
    An object with rendering-related options. At present, only the 'offScreenTarget' option is implemented (for webgl), and it defaults to false.

    (layerId,
    resolutionFactor)
    Set the resolution factor for a specific layer

    Parameters:


    {number}layerId
    The layer id
    {number}resolutionFactor
    The resolution factor. It must be > 0. 1 indicates full resolution, < 1 lower resolution, > 1 higher resolution.

    (layerId,
    toggle)
    Enable or disable image smoothing for a specific layer. This determines the type of filtering that is applied to stretched images (nearest-neighbor filtering is used when smoothing is disabled). Note that smoothing is true by default.

    Parameters:


    {number}layerId
    The id of the affected layer
    {boolean}toggleOptional
    Whether to enable or disable image smoothing for the layer. If not specified, "true" is assumed.

    (layerId,
    sortingType)
    Set the sorting method to use for a specified layer

    Parameters:


    {number}layerId
    The layer id
    {string|function}sortingType
    A user-defined function to use for sorting the layer, or a string indicating one of the built-in types of sorting: 'bottomToTop', 'topToBottom', 'none'.
    A sorting function looks like 'function sort(a, b)' where 'a' and 'b' are two sprites. The function returns a negative number if 'a' needs to be drawn before 'b', and a positive number otherwise.
    The default sorting type is 'none', which means that objects will be drawn in the order they were added to the scene

    (layerId,
    scale,
    translate)
    Set a coordinate transformation for the layer. This will determine how the objects in the layer are rotated and translated when the camera moves

    Parameters:


    {number}layerId
    The layer id
    {number}scale
    The scale transformation factor. The default value is 1. A value of 0 indicates that no scaling will occur when the camera moves. Higher values indicate more scaling.
    {number}translate
    The transformation factor. The default value is 1. A value of 0 indicates that no translation will occur when the camera moves. Higher values indicate larger translations.

    (visible,
    position,
    backColor,
    foreColor)
    Display (or hide) a progress bar that indicates the current loading progress

    Parameters:


    {boolean}visibleOptional
    Whether to show the loading bar or not. If omitted, this parameter is assumed to be false.
    {Object}positionOptional
    An object with x and y fields describing the position in pixels (relative to the screen center) where the loading bar should appear. This is only relevant if the visible parameter is true.
    {string}backColorOptional
    A HTML color string to use as the background color of the loading bar
    {string}foreColorOptional
    A HTML color string to use as the foreground color of the loading bar

    (files,
    link)
    Set the loading image(s) to be displayed while loading data

    Parameters:


    {string|Array}files
    An image file name, or an array of image file names. These images don't need to be loaded using loadImage
    {string}linkOptional
    An URL to open when the loading image is clicked. The link is opened in a new window (or tab).

    (callback,
    name,
    priority)
    Set or remove a callback to be executed after each simulation step. Callbacks can be named, and you can have multiple ones active at the same time (although only one for each name).

    Parameters:


    {function}callbackOptional
    The function to be executed after each simulation step. You can use a falsy value here (such as 0) to disable the callback
    {string}nameOptional
    The name you want to give to the callback. Subsequent calls to setMainLoop() with the same name, will replace the callback you are setting now.
    {number}priorityOptional
    When there are multiple callbacks, they will be executed in ascending order of priority. Default is 0

    (width,
    height)
    Set the maximum width and height of the render area. When the window mode is set to full, even when the render area is automatically resized it will never be larger than the specified dimensions.
    The default values are 1920 and 1080

    Parameters:


    {number}width
    The maximum width of the render area
    {number}height
    The maximum height of the render area

    (type,
    interval)
    Set the minimum time between input events of the same type. Events occurring before the specified interval will be ignored.

    Parameters:


    {string}type
    The input event type. Valid values are 'mouseDown', 'mouseUp', 'mouseMove' and 'mouseWheel'
    {number}interval
    The minimum interval between events of the same type, in milliseconds

    (width,
    height)
    Set the minimum width and height of the render area. When the window mode is set to full, even when the render area is automatically resized it will never be smaller than the specified dimensions.
    The default values are 0 and 0

    Parameters:


    {number}width
    The minimum width of the render area
    {number}height
    The minimum height of the render area

    (layerId,
    shaderSource,
    shaderUniforms)
    Set a post-process shader for a layer

    Parameters:


    {number}layerId
    The ID of the layer
    {string}shaderSourceOptional
    The contents of a "main(void)" fragment shader function. If omitted or empty, the default pixel shader is used, resulting in no post-processing.
    {string}shaderUniformsOptional
    An object that specifies the name and type of custom shader uniforms that you want to use. For example {tintColor: 'vec4'}. Values will be retrieved from public properties of the Sprite using the same name. So in this example, make sure that your sprite has got a property called tintColor that is an array with 4 elements. Supported types are currently: float, vec2, vec3, vec4, int, ivec2, ivec3, ivec4 and sampler2D.

    (_resolutionFactor)
    Set the resolution factor for all layers

    Parameters:


    {number}_resolutionFactor
    The resolution factor. It must be > 0. 1 indicates full resolution, < 1 lower resolution, > 1 higher resolution.

    (sceneObject,
    index)
    Set the index of a scene object in the scene. You may want to do this if you care about SceneObjects being exported in a specific order with wade.exportScene().

    Parameters:


    {SceneObject}sceneObject
    The SceneObject
    {number}index
    The desired index in the scene

    Returns:


    {number}
    The actual index of the SceneObject in the scene after attempting this operation. If the scene has N objects, and you try to set the index to a number greater than N-1, the object will be moved at index N-1 instead. If the object hasn't been added to the scene yet, this function will return -1.

    (width,
    height)
    Set the size of the render area. Note that, depending on the current window mode, changing the size of the render area may have no actual effect, although an onResize event will always be fired if the width and height specified are not the same as the current ones.

    Parameters:


    {number}width
    The width of the render area
    {number}height
    The height of the render area

    (file,
    data,
    setForPreloader)
    Associate a file name with a script, so that any subsequent calls to getScript using the given file name will return that script.

    Parameters:


    {string}file
    The script file name
    {string}dataOptional
    A string representation of the script
    {boolean}setForPreloaderOptional
    Whether to apply this operation to the asset preloader as well as the asset loader. This is false by default. If set to true, subsequent calls to wade.preloadScript will get this cached version of the data instead of loading it again in the background.

    (toggle)
    Enable or disable image smoothing for all layers. This determines the type of filtering that is applied to stretched images (nearest-neighbor filtering is used when smoothing is disabled). Note that smoothing is true by default.

    Parameters:


    {boolean}toggleOptional
    Whether to enable or disable image smoothing. If not specified, "true" is assumed.

    (tolerance,
    numSamples)
    Set the tolerance for swipe events.

    Parameters:


    {number}tolerance
    The tolerance value to use for swipe events. Default is 1.
    {number}numSamplesOptional
    The number of samples used for gesture detection. Default is 1.

    (file,
    data,
    setForPreloader)
    Associate a file name with a text string, so that any subsequent calls to getText using the given file name will return that string.

    Parameters:


    {string}file
    The text file name
    {string}dataOptional
    The data object to associate with the text file name
    {boolean}setForPreloaderOptional
    Whether to apply this operation to the asset preloader as well as the asset loader. This is false by default. If set to true, subsequent calls to wade.preloadText will get this cached version of the data instead of loading it again in the background.

    (f,
    time)
    Schedule the execution of a function. This is similar to JavaScript's native setTimeout function, but it depends on the app simulation time (that can be paused programmatically or when the app is running in a background tab) rather than the actual clock time.

    Parameters:


    {function}f
    A function to execute
    {number}time
    The app simulation time, in milliseconds, to wait until the function is executed

    Returns:


    {number}
    A unique ID that can be used to cancel the timeout via wade.clearTimeout()

    (mode)
    Set the current window mode. This determines how the render area will be resized when the parent window is resized.

    Parameters:


    {string}mode
    The window mode. Valid values are:
    'full' - The render area will be resized to cover the whole window, as long as it's between the minimum and maximum screen sizes (see setMinScreenSize and setMaxScreenSize)
    'stretchToFit' - The render area will be resized to cover as much as possible of the parent window, without changing its aspect ratio
    any other string - The render area will never be resized
    The default value is 'full'

    (sceneObject,
    toggle)
    Enable or disable the simulation of a scene object

    Parameters:


    {SceneObject}sceneObject
    The scene object
    {boolean}toggle
    Whether to enable the simulation

    (domain)
    Only allow the WADE App to be executed on a specific domain. Note that this will still allow you to execute the app on your localhost or 127.0.0.1, regardless of the domain specified

    Parameters:


    {string}domain
    The domain where you want the WADE App to be executed. For example 'www.clockworkchilli.com'
    ()
    Skip any frames that have been missed due to lag up to this point (don't try to catch up). This won't affect future missed frames, i.e. WADE will still try to catch up on those unless you call skipMissedFrames again.


    (timeline,
    time,
    timelineId)
    Start a timeline. A timeline is a series of events, each associated with some code to execute and a time (in seconds) since the start of the timeline.
    The reference time can be either the app's simulation time, or the system clock, and can be set in timeline.referenceTime. Please consider how you want variable framerate to affect your timing when you choose a value for this. Note that code won't be execute while the simulation isn't running, regardless of the type of referenceTime. However, the app time is paused while the simulation is paused, the clock time is not.


    Parameters:


    {Object}timeline
    A timeline object with the following structure:
    {
        referenceTime: string (it can be either 'app' or 'clock' - if unspecified, it defaults to 'app')
        events: [{time: number, code: string}, {time: number, code: string}]
    }
    
    {number}timeOptional, Default: 0
    The starting point of the timeline
    {string}timelineIdOptional
    The ID of an existing timeline that you want to replace. If null or unspecified, a new timeline will be created

    Returns:


    {string}
    The id of the new timeline. This can be used to call wade.stopTimeline() and wade.resumeTimeline()
    ()
    Stop the execution of the WADE app. The simulation and rendering loops will be interrupted, and 'onAppTimer' events will stop firing.
    If the WADE app has scheduled any events (for example with setTimeout), it is responsible for cancelling those events.


    (uid)
    Stop an audio file that was playing

    Parameters:


    {number}uidOptional
    The unique identifier of the audio source that you want to stop playing. If omitted, all sources will be stopped
    ()
    Stop listening for input events


    (timelineId)
    Stop an active timeline

    Parameters:


    {string}timelineId
    The ID of the timeline, as obtained by a previous call to wade.startTimeline()

    (name,
    object)
    Store an object or array in the local storage. Note that the object must be serializable, so you cannot store objects with cyclic references

    Parameters:


    {string}name
    The name to give the object. This can later be used with a call to retrieveLocalObject
    {object|Array}object
    The object to store
    ()
    Release references to all the audio files that have been loaded so far, so they can be garbage-collected to free some memory

    ()
    Release references to all the image files that have been loaded so far, so they can be garbage-collected to free some memory


    (file)
    Release references to an audio file, so it can be garbage-collected to free some memory

    Parameters:


    {string}file
    An audio file to unload. It can be a relative path, or an absolute path starting with "http://"

    (file)
    Release references to an image file, so it can be garbage-collected to free some memory

    Parameters:


    {string}file
    An image file to unload. It can be a relative path, or an absolute path starting with "http://"

    (spriteSheet,
    destinations,
    numCellsX,
    numCellsY,
    unload)
    Create a separate image (more specifically an off-screen canvas) for each sprite in the sprite sheet

    Parameters:


    {string}spriteSheet
    The path of the input sprite sheet
    {Array}destinationsOptional
    An array with the virtual paths for the single images, that can later be used to retrieve the canvas objects via wade.getImage(). If omitted, destination images will be called [spriteSheetName]_0, [spriteSheetName]_1, [spriteSheetName]_2, etc.
    {number}numCellsXOptional, Default: 1
    The number of horizontal cells
    {number}numCellsYOptional, Default: 1
    The number of vertical cells
    {boolean}unloadOptional
    Whether to unload the sprite sheet after unpacking

    (layerId,
    toggle)
    Enable or disable quadtree optimization for a specific layer. Note that this optimization is enabled by default, so normally you don't need to call this function. Sometimes you may want to wade.useQuadtree(layerId, false) for layers that have lots of small moving objects that you don't need to know the exact positions of, such as particles.

    Parameters:


    {number}layerId
    The id of the layer for which you want to enable/disable the quadtree optimization
    {boolean}toggleOptional
    Whether to enable or disable the quadtree. If omitted, this parameter is assumed to be true.

    (data)
    A function to log any warning message from WADE. By default, this is set to console.warn

    Parameters:


    {*}data
    The data to log

    (domains)
    Only allow the App to be linked only from selected domains

    Parameters:


    {string|Array}domains
    A string (or an array of strings) representing the allowed domain(s)

    (layerId,
    box)
    Transform a world space box into canvas space

    Parameters:


    {number}layerId
    The id of the layer to use. This determines the translation and scale factors to use in the transformation.
    {Object}box
    An object whose 'minX', 'minY', 'maxX' and 'maxY' fields represent a world space box

    Returns:


    {Object}
    An object whose 'minX', 'minY', 'maxX' and 'maxY' fields represent a canvas space box

    (layerId,
    box)
    Transform a world space box into screen space

    Parameters:


    {number}layerId
    The id of the layer to use. This determines the translation and scale factors to use in the transformation.
    {Object}box
    An object whose 'minX', 'minY', 'maxX' and 'maxY' fields represent a world space box

    Returns:


    {Object}
    An object whose 'minX', 'minY', 'maxX' and 'maxY' fields represent a screen space box

    (layerId,
    direction)
    Transform a world space direction into canvas space

    Parameters:


    {number}layerId
    The id of the layer to use. This determines the translation and scale factors to use in the transformation.
    {Object}direction
    An object whose 'x' and 'y' fields represent a world space direction

    Returns:


    {Object}
    An object whose 'x' and 'y' fields represent a canvas space direction

    (layerId,
    direction)
    Transform a world space direction into screen space

    Parameters:


    {number}layerId
    The id of the layer to use. This determines the translation and scale factors to use in the transformation.
    {Object}direction
    An object whose 'x' and 'y' fields represent a world space direction

    Returns:


    {Object}
    An object whose 'x' and 'y' fields represent a screen space direction

    (layerId,
    position)
    Transform a world space position into canvas space

    Parameters:


    {number}layerId
    The id of the layer to use. This determines the translation and scale factors to use in the transformation.
    {Object}position
    An object whose 'x' and 'y' fields represent a world space position

    Returns:


    {Object}
    An object whose 'x' and 'y' fields represent a canvas space position

    (layerId,
    position)
    Transform a world space position into screen space

    Parameters:


    {number}layerId
    The id of the layer to use. This determines the translation and scale factors to use in the transformation.
    {Object}position
    An object whose 'x' and 'y' fields represent a world space position

    Returns:


    {Object}
    An object whose 'x' and 'y' fields represent a screen space position

    (layerId)
    Get the size (in canvas pixels) of a world-space unit

    Parameters:


    {number}layerId
    The id of the layer to use. This determines the translation and scale factors to use in the transformation.

    Returns:


    {number}
    The size of a world-space unit in canvas pixels

    (layerId)
    Get the size (in screen pixels) of a world-space unit

    Parameters:


    {number}layerId
    The id of the layer to use. This determines the translation and scale factors to use in the transformation.

    Returns:


    {number}
    The size of a world-space unit in screen pixels