Classes


Class Wade


Version 3.2.

Class Summary
Constructor Attributes Constructor Name and Description
 
Wade()
WADE - Web App Development Engine.
Field Summary
Field Attributes Field Name and Description
 
app
The current app instance
<constant>  
The time (in seconds) between simulation steps
 
The default layer for new sprites.
Method Summary
Method Attributes Method Name and Description
 
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.
 
addSceneObject(sceneObject, autoListen, params)
Add a scene object to the scene
 
Check to see if gamepads are supported in the current browser
 
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
 
clearCanvas(layerId)
Clear the canvas(es) associated with a specific layer.
 
Remove all the scene objects from the scene
 
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.
 
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 memory
 
Enable or disable double buffering for the on-screen canvases.
 
Enabled or disable gamepad support
 
Enable or disable support for multi touch.
 
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 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)
 
getLayerCanvas(layerId)
Get the canvas object being used by 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
 
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
 
Get the current version of WADE as a string.
 
If WebAudio is supported, get the current WebAudio context
 
Get the current window mode.
 
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
 
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.
 
log(data)
A function to log any error or warning 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
 
playAudioIfAvailable(file, looping, callback)
Play an audio file only if it's ready to be played, do not attempt to play otherwise
 
playAudioSegment(file, start, end, callback)
Play a segment of an audio file
 
playAudioSegmentIfAvailable(file, start, end, callback)
Play a segment of an audio file only if it's ready to be played, do not attempt to play otherwise
 
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.
 
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
 
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)
 
Retrieve an object from the local storage, that has previously been saved through storeLocalObject()
 
screenBoxToWorld(layerId, box)
Transform a screen space box into world space
 
screenCapture(imageName)
Draw the contents of the WADE screen to an image in 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.
 
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.
 
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.
 
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
 
setMainLoopCallback(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.
 
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.
 
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).
 
stop()
Stop the execution of the WADE app.
 
stopAudio(uid)
Stop an audio file that was playing
 
Stop listening for input events
 
storeLocalObject(name, object)
Store an object 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
 
Release references to an audio file, so it can be garbage-collected to free some memory
 
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.
 
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
Class Detail
Wade()
WADE - Web App Development Engine.
Field Detail
app
The current app instance

<constant> c_timeStep
The time (in seconds) between simulation steps

defaultLayer
The default layer for new sprites. This is initially set to 1.
Method Detail
addEventListener(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

addGlobalEventListener(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

{SceneObject} addSceneObject(sceneObject, autoListen, params)
Add a scene object to the scene
Parameters:
{SceneObject} sceneObject
The scene object to add to the scene
{boolean} autoListen Optional
This is false by default. When set to true (or a truthy value), 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 addded 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.
params Optional
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

{boolean} areGamepadsSupported()
Check to see if gamepads are supported in the current browser
Returns:
{boolean} Whether gamepads are supported in the current browsers

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. 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} toggle Optional
Whether to auto-load images or not. If omitted this is assumed to be true.

blacklistReferrers(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)

{boolean} boxContainsBox(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

{boolean} boxContainsPoint(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

{boolean} boxIntersectsBox(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

{boolean} boxIntersectsOrientedBox(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}

cancelInputEvents(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} toggle Optional
Whether to cancel the normal handling of event. If this parameter is omitted, it's assumed to be true.

{Object} canvasBoxToWorld(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

{Object} canvasDirectionToWorld(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

{Object} canvasPositionToWorld(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

{number} canvasUnitToWorld(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

clampBoxToBox(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'

clearCanvas(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

clearScene()
Remove all the scene objects from the scene

{Array} cloneArray(array)
Clone an array
Parameters:
{Array} array
The array to clone
Returns:
{Array} A clone of the original array

{Object} cloneObject(object)
Clone an object
Parameters:
{Object} object
The object to clone
Returns:
{Object} A clone of the original object

{HTMLElement} createCanvas(resolutionFactor)
Create an HTML5 canvas object and add it to the document
Parameters:
{number} resolutionFactor Optional
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}

createPseudoArray(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.

deleteCanvases()
Delete all the canvas objects created by WADE

draw(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} layerIds Optional
The id of the layer (or layers) to draw. If omitted, the whole scene will be drawn

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

enableDoubleBuffering(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} toggle Optional
whether to enable or disable double buffering

enableGamepads(toggle)
Enabled or disable gamepad support
Parameters:
{boolean} toggle Optional
Whether to enable or disable gamepad support. If omitted, this parameter is assumed to be true.

enableMultitouch(toggle)
Enable or disable support for multi touch. Multi touch is disabled by default.
Parameters:
{boolean} toggle Optional
Whether to enable or disable multi touch. This parameter is true by default.

expandBox(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'

{object|string} 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()
Parameters:
{boolean} stringify Optional
Whether the result should be serialized to a JSON string
{Array} exclude Optional
An array of scene objects and path (or their names) to exclude from the exported scene
{boolean} exportObjectFunctions Optional
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)

fadeInLayer(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} callback Optional
A function to execute when the fading is complete

fadeOutLayer(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} callback Optional
A function to execute when the fading is complete

forceOrientation(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} orientation Optional
The orientation to use. This can be 'landscape', 'portrait', or any other string (to disable forced orientation).

forceRedraw(layerId)
Force the full redraw of the scene (or of a single layer)
Parameters:
{number} layerId Optional
The id of the layer to redraw. If omitted or falsy, all layers will be redrawn.

forEachPixel(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} targetImage Optional
The file name (or virtual path) of the target image. If omitted, the source image will be overwritten with the new data.

{Array} getActiveLayerIds()
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

{number} getAppTime()
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

{String} getBasePath()
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

{Object} getCameraPosition()
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

{number} getCatchUpBuffer()
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

{number} getContainerHeight()
Get the height of the window that contains the app
Returns:
{number} The height of the window that contains the app

{string} getContainerName()
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

{number} getContainerWidth()
Get the width of the window that contains the app
Returns:
{number} The width of the window that contains the app

{string} getFont(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

{string} getForcedOrientation()
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'

{string} getFullPathAndFileName(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

{string} getHostName(url)
Get the host name based on a URL string
Parameters:
{string} url
The URL string
Returns:
{string} The host name

{Object} getImage(file, errorMessage)
Get an image object that has previously been loaded, or a blank image
Parameters:
{string} file Optional
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} errorMessage Optional
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

{ImageData} getImageData(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} posX Optional
The left coordinate of the data to retrieve. Default is 0.
{number} posY Optional
The top coordinate of the data to retrieve. Default is 0.
{number} width Optional
The width of the image data to retrieve. By default this is the whole width of the image.
{number} height Optional
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.

{string} getImageDataURL(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

{object|Array} getJson(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

{Object} getLayerCanvas(layerId)
Get the canvas object being used by a layer. You can use it as a source image for sprite and effects.
Parameters:
{number} layerId Optional
The id of the layer to use. Default is 1
Returns:
{Object} An HTML5 canvas object

{string} getLayerDataURL(layerId)
Generate a data URL from a game layer
Parameters:
{number} layerId
The layer Id
Returns:
{string} A base64 data URL

{number} getLayerOpacity(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)

{string} getLayerRenderMode(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'

{number} getLayerResolutionFactor(layerId)
Get the resolution factor for a specific layer
Parameters:
{number} layerId
The layer id
Returns:
{number} The resolution factor of the layer

{boolean} getLayerSmoothing(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

{string|function} getLayerSorting(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'.

{number} getLoadingPercentage()
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

{string | undefined} getLoadingStatus(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

{number} getMaxScreenHeight()
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

{number} getMaxScreenWidth()
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

{number} getMinScreenHeight()
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

{number} getMinScreenWidth()
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

{object} getMousePosition()
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

{Array} getObjectsInArea(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} layerId Optional
If specified, the object search will be restricted to this layer id
Returns:
{Array} An array of scene objects

{Array} getObjectsInScreenArea(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

{number} getResolutionFactor()
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

{SceneObject} getSceneObject(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

{number} getSceneObjectIndex(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

{Array} getSceneObjects(property, value)
Get a list of all the objects in the scene, or just the objects with a given property/value pair.
Parameters:
{string} property Optional
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.
{*} value Optional
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

{number} getScreenHeight()
Get the hight of the current render area
Returns:
{number} The height of the current render area

{number} getScreenWidth()
Get the width of the current render area
Returns:
{number} The width of the current render area

{string} getScript(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

{boolean} getSmoothing()
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

{Array} getSpritesInArea(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} layerId Optional
If specified, the sprite search will be restricted to this layer id
{boolean} sorted Optional
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

{Array} getSpritesInScreenArea(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

{string} getVersion()
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.

{AudioContext} getWebAudioContext()
If WebAudio is supported, get the current WebAudio context
Returns:
{AudioContext} The current WebAudio context. If WebAudio is not supported, this function returns undefined.

{string} getWindowMode()
Get the current window mode.
Returns:
{string} The current window mode.

{number} hashString(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

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. 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
            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}} loadingBar Optional
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} callback Optional
A function to execute when the scene has been imported
{boolean} async Optional
Whether the scene should be loaded asynchronously in the background, without blocking the simulation and rendering of the app. False by default
{boolean} clearScene Optional
Whether the current scene should be cleared before adding objects for the new scene. False by default

init(appScript, appData, options)
Initialize the engine
Parameters:
{string} appScript
Path and filename of the main app script
{Object} appData Optional, Default: {}
An object containing initialization data for the app
{Object} options Optional, 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.

initializeApp()
Initialize the user app. This function is called automatically when the main app is finished loading its assets.

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

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

{boolean} isAutoLoadingImages()
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.

{boolean} isDebugMode()
Check whether we are currently running in debug mode
Returns:
{boolean} Whether we are currently running in debug mode

{boolean} isDoubleBufferingEnabled()
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

{boolean} isEventListener(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

{boolean} isKeyDown(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

{boolean} isMouseDown(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} buttonId Optional
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

isMultitouchEnabled()
Check whether multi touch support is current enabled. By default it's disabled, unless you call wade.enableMultitouch()

{boolean} isScreenRotated()
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}

{boolean} isUsingQuadtree(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

{boolean} isWebAudioSupported()
Checks whether the WebAudio API is supported by the client
Returns:
{boolean} whether the WebAudio API is supported

{boolean} isWebGlSupported()
Check to see if WebGL is supported
Returns:
{boolean} Whether WebGL is supported in the current environment

loadAudio(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} autoplay Optional
Whether to start play the audio file as soon as it's ready.
{boolean} looping Optional
Whether to repeat the audio when it's over
{function} callback Optional
A function to execute when the audio is ready to play
{function} errorCallback Optional
A callback to execute when the audio file cannot be loaded

loadFont(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} callback Optional
A callback to execute when the file is loaded
{function} errorCallback Optional
A callback to execute when the font cannot be loaded

loadImage(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} callback Optional
A callback to execute when the file is loaded
{function} errorCallback Optional
A callback to execute when the image cannot be loaded

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.
Parameters:
{Array} arrayOfFileNames
An array of strings, where each string is the file name of an image to load.

loadJson(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} objectToStoreData Optional
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} callback Optional
A callback to execute when the script is loaded
{boolean} forceReload Optional
Whether to force the client to reload the file even when it's present in its cache#
{function} errorCallback Optional
A callback to execute when the json file cannot be loaded

loadPage(url)
Open a web page in the app's window.
Parameters:
{string} url
The address of the web page to open

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. 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}} loadingBar Optional
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} callback Optional
A function to execute when the scene has been loaded
{boolean} clearScene Optional
Whether the previous scene should be cleared before adding objects for the new scene. False by default

loadScript(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} callback Optional
A callback to execute when the script is loaded
{boolean} forceReload Optional
Wheter to force the client to reload the file even when it's present in its cache
{function} errorCallback Optional
A callback to execute when the script cannot be loaded
{boolean} dontExecute Optional
Scripts loaded via wade.loadScript() are automatically executed. Set this boolean to true to avoid executing them as they are loaded.

log(data)
A function to log any error or warning message from WADE. By default, this is set to console.log
Parameters:
{*} data
The data to log

moveCamera(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} speed Optional
The movement speed. This can be a number, or a function of distance that returns a number
{function} callback Optional
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.

{boolean} orientedBoxContainsPoint(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

{boolean} orientedBoxIntersectsBox(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}

{boolean} orientedBoxIntersectsOrientedBox(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

pauseSimulation(mainLoopName)
Pause the simulation
Parameters:
{string} mainLoopName Optional
The name of the main loop that you want to pause. If omitted, the whole simulation will be paused.

{number} playAudio(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} callback Optional
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

{number} playAudioIfAvailable(file, looping, callback)
Play an audio file only if it's ready to be played, do not attempt to play otherwise
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} callback Optional
A function to call when the sound is finished playing
Returns:
{number} a unique identifier of the audio source that is being played

{number} playAudioSegment(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} start Optional
The starting point, in seconds. If omitted or falsy, the sound will be played from the beginning
{number} end Optional
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} callback Optional
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

playAudioSegmentIfAvailable(file, start, end, callback)
Play a segment of an audio file only if it's ready to be played, do not attempt to play otherwise
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} start
The starting point, in seconds
{number} end
The ending point, in seconds
{function} callback
A function to call when the ending point is reached

postObject(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)

preloadAudio(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} autoplay Optional
Whether to start play the audio file as soon as it's ready.
{boolean} looping Optional
Whether to repeat the audio when it's over
{function} callback Optional
A function to execute when the audio is ready to play
{function} errorCallback Optional
A callback to execute when the audio file cannot be loaded

preloadFont(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} callback Optional
A callback to execute when the file is loaded
{function} errorCallback Optional
A callback to execute when the font cannot be loaded

preloadImage(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} callback Optional
A callback to execute when the file is loaded
{function} errorCallback Optional
A callback to execute when the image cannot be loaded

preloadJson(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} objectToStoreData Optional
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} callback Optional
A callback to execute when the script is loaded
{boolean} forceReload Optional
Whether to force the client to reload the file even when it's present in its cache
{function} errorCallback Optional
A callback to execute when the json file cannot be loaded

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. 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}} loadingBar Optional
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} callback Optional
A function to execute when the scene has been loaded
{boolean} clearScene Optional
Whether the previous scene should be cleared before adding objects for the new scene. False by default

preloadScript(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} callback Optional
A callback to execute when the script is loaded
{boolean} forceReload Optional
Wheter to force the client to reload the file even when it's present in its cache
{function} errorCallback Optional
A callback to execute when the script cannot be loaded
{boolean} dontExecute Optional
Scripts loaded via wade.preloadScript() are automatically executed. Set this boolean to true to avoid executing them as they are loaded.

preventIframe()
Prevent the WADE App from being executed inside an iframe

{boolean} processEvent(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} eventData Optional
An object to be passed to all the callbacks that will be called
Returns:
{boolean} Whether any listener succesfully processed the event

putImageData(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} destX Optional
The left coordinate of the destination image (where the data is going to copied). Default is 0.
{number} destY Optional
The top coordinate of the destination image (where the data is going to copied). Default is 0.
{number} sourceX Optional
The left coordinate of the source data to copy. Default is 0.
{number} sourceY Optional
The top coordinate of the source data to copy. Default is 0.
{number} width Optional
The width of the data to copy. By default this is the whole width of the source image data.
{number} height Optional
The height of the data to copy. By default this is the whole height of the source image data.

recreateCanvases()
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.
Parameters:
{SceneObject} sceneObject
The scene object to unregister
{string} event
The name of the event to stop listening for

removeGlobalEventListener(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

removeLayer(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} removeObjectFromArray(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

{Object} removeObjectFromArrayByIndex(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

removeSceneObject(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.

removeSceneObjects(sceneObjects)
Remove multiple scene objects from the scene
Parameters:
{Array} sceneObjects
An array of scene objects to remove from the scene

removeUnusedLayers(exceptions)
Remove all layers that contain no sprites, and release all the associated resources
Parameters:
{Array} exceptions Optional
An array of layer id's that you do NOT want to remove even if unused

requireVersion(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} errorMode Optional
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} errorMessage Optional
The error message to display. Default is 'A newer version of WADE is required;.

restartInputEvents()
Restart listening to input events after a call to wade.stopInputEvents()

resumeSimulation(mainLoopName)
Resume the simulation (typically after it was paused via wade.pauseSimulation)
Parameters:
{string} mainLoopName Optional
The name of the main loop that you want to resume. If omitted, the whole simulation will be resumed.

retrieveLocalObject(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

{Object} screenBoxToWorld(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

screenCapture(imageName)
Draw the contents of the WADE screen to an image in memory
Parameters:
{string} imageName
The file name (or virtual path) of the target image

{Object} screenDirectionToWorld(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

{Object} screenPositionToWorld(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

{number} screenUnitToWorld(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

setAppTimerInterval(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

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.
Parameters:
{string} file
The audio file name
{Object} audio Optional
The audio object
{function} callback Optional
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} setForPreloader Optional
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.

setBasePath(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

setCameraPosition(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

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

setCanvasClearing(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

setCatchUpBuffer(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

setClickTolerance(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} tolerance Optional
The tolerance for "onClick" events, in pixels.

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.
Parameters:
{string} file
The font file name
{string} data Optional
The dataURL of the font
{boolean} setForPreloader Optional
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.

setFullScreen(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} toggle Optional
Whether to enable or disable full screen mode. If not specified, "true" is assumed.

setGlobalLoadingCallback(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

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.
Parameters:
{string} file
The image file name
{Object} image Optional
The image object
{boolean} setForPreloader Optional
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.

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.
Parameters:
{string} file
The JSON file name
{Object} data Optional
The data object to associate with the JSON file name
{boolean} setForPreloader Optional
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.

setLayer3DTransform(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} transformString Optional
Any valid CSS 3D transform string. Omitting this parameter resets the transform
{string} transformOrigin Optional
Any valid CSS 3D transform-origin string. Omitting this parameter resets the transform origin to (50% 50%)
{number} time Optional
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} callback Optional
A function to execute when the transform has been applied

setLayerOpacity(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)

setLayerRenderMode(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} options Optional
An object with rendering-related options. At present, only the 'offScreenTarget' option is implemented (for webgl), and it defaults to false.

setLayerResolutionFactor(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.

setLayerSmoothing(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} toggle Optional
Whether to enable or disable image smoothing for the layer. If not specified, "true" is assumed.

setLayerSorting(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

setLayerTransform(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.

setLoadingBar(visible, position, backColor, foreColor)
Display (or hide) a progress bar that indicates the current loading progress
Parameters:
{boolean} visible Optional
Whether to show the loading bar or not. If omitted, this parameter is assumed to be false.
{Object} position Optional
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} backColor Optional
A HTML color string to use as the background color of the loading bar
{string} foreColor Optional
A HTML color string to use as the foreground color of the loading bar

setLoadingImages(files, link)
Set the loading image(s) to be displayed while loading data
Parameters:
{string|Array} files
An image file name, or an arrray of image file names. These images don't need to be loaded using loadImage
{string} link Optional
An URL to open when the loading image is clicked. The link is opened in a new window (or tab).

setMainLoopCallback(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} callback Optional
The function to be executed after each simulation step. You can use a falsy value here (such as 0) to disable the callback
{string} name Optional
The name you want to give to the callback. Subsequent calls to setMainLoopCallback() with the same name, will replace the callback you are setting now.
{number} priority Optional
When there are multiple callbacks, they will be executed in ascending order of priority. Default is 0

setMaxScreenSize(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

setMinimumInputEventInterval(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

setMinScreenSize(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

setResolutionFactor(_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.

{number} setSceneObjectIndex(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.

setScreenSize(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

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.
Parameters:
{string} file
The script file name
{string} data Optional
A string representation of the script
{boolean} setForPreloader Optional
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.

setSmoothing(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} toggle Optional
Whether to enable or disable image smoothing. If not specified, "true" is assumed.

setSwipeTolerance(tolerance, numSamples)
Set the tolerance for swipe events.
Parameters:
{number} tolerance
The tolerance value to use for swipe events. Default is 1.
{number} numSamples Optional
The number of samples used for gesture detection. Default is 1.

setWindowMode(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'

simulateSceneObject(sceneObject, toggle)
Enable or disable the simulation of a scene object
Parameters:
{SceneObject} sceneObject
The scene object
{boolean} toggle
Whether to enable the simulation

siteLock(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'

skipMissedFrames()
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.

stop()
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.

stopAudio(uid)
Stop an audio file that was playing
Parameters:
{number} uid Optional
The unique identifier of the audio source that you want to stop playing. If omitted, all sources will be stopped

stopInputEvents()
Stop listening for input events

storeLocalObject(name, object)
Store an object 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} object
The object to store

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

unloadAllImages()
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
Parameters:
{string} file
An audio file to unload. It can be a relative path, or an absolute path starting with "http://"

unloadImage(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://"

unpackSpriteSheet(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} destinations Optional
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} numCellsX Optional, Default: 1
The number of horizontal cells
{number} numCellsY Optional, Default: 1
The number of vertical cells
{boolean} unload Optional
Whether to unload the sprite sheet after unpacking

useQuadtree(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} toggle Optional
Whether to enable or disable the quadtree. If omitted, this parameter is assumed to be true.

whitelistReferrers(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)

{Object} worldBoxToCanvas(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

{Object} worldBoxToScreen(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

{Object} worldDirectionToCanvas(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

{Object} worldDirectionToScreen(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

{Object} worldPositionToCanvas(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

{Object} worldPositionToScreen(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

{number} worldUnitToCanvas(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

{number} worldUnitToScreen(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

Documentation generated by JsDoc Toolkit 2.4.0 on Tue Jul 12 2016 07:54:41 GMT+0100 (BST)