## Constructors

- [Animation](/content/docs/Animation/index.html)
- [IsoCharacter](/content/docs/IsoCharacter/index.html)
- [Path](/content/docs/Path/index.html)
- [PhysicsObject](/content/docs/PhysicsObject/index.html)
- [SceneObject](/content/docs/SceneObject/index.html)
- [SceneObjectGroup](/content/docs/SceneObjectGroup/index.html)
- [Sprite](/content/docs/Sprite/index.html)
- [TextSprite](/content/docs/TextSprite/index.html)
- [TilemapCharacter](/content/docs/TilemapCharacter/index.html)
- [wade](/content/docs/wade/index.html)
- [wade.drawFunctions](/content/docs/wade.drawFunctions)
- [wade.iso](/content/docs/wade.iso)
- [wade.physics](/content/docs/wade.physics)
- [wade.tilemap](/content/docs/wade.tilemap)
- [wade.vec2](/content/docs/wade.vec2)

## wade

# Constructor Summary

# Fields Summary

**wade.app**

The current app instance

**wade.c\_timeStep**

The time (in seconds) between simulation steps

**wade.defaultLayer**

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

# Functions Summary

**wade.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).

**wade.addGlobalEventListener** _(sceneObject, event)_

**wade.addPath** _(path)_

Add a Path to the scene

**wade.addSceneObject** _(sceneObject, autoListen, params)_

Add a scene object to the scene

**wade.addSceneObjectGroup** _(sceneObjectGroup)_

Add a SceneObjectGroup to the scene

**wade.ajax** _(params)_

Perform an asynchronous HTTP request

**wade.alwaysUpdateBlur** _(layerId, toggle)_

Force an update of the blur texture for a specific layer even when the blur amount is set to 0 for that layer

**wade.areGamepadsSupported** _()_

Check to see if gamepads are supported in the current browser

**wade.areGlLayersMerged** _()_

Check whether WebGL layers are currently merged (i.e. they share the same context where possible). See mergeGlLayers for details.

**wade.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.

**wade.blacklistReferrers** _(domains)_

Do not allow the App to be linked from selected domains

**wade.boxContainsBox** _(box1, box2)_

Check whether box1 contains box2

**wade.boxContainsPoint** _(box, point)_

Check whether a box contains a point

**wade.boxIntersectsBox** _(box1, box2)_

Check whether box1 and box2 intersect each other

**wade.boxIntersectsOrientedBox** _(box, ob)_

Check whether an axis-aligned box and an oriented box overlap each other.

**wade.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.

**wade.canvasBoxToWorld** _(layerId, box)_

Transform a canvas space box into world space

**wade.canvasDirectionToWorld** _(layerId, direction)_

Transform a canvas space direction into world space

**wade.canvasPositionToWorld** _(layerId, position)_

Transform a canvas space position into world space

**wade.canvasUnitToWorld** _(layerId)_

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

**wade.clampBoxToBox** _(box1, box2)_

Resize box1 so that it's fully contained in box2

**wade.clearAllTimeoutsAndIntervals** _()_

Remove any active timeouts or intervals that have been set via _wade.setTimeout()_ or _wade.setInterval()_

**wade.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.

**wade.clearInterval** _(intervalUid)_

Cancel an interval that was previously scheduled with _wade.setInterval()_

**wade.clearScene** _()_

Remove all the scene objects from the scene

**wade.clearTimelines** _()_

Stop and delete all timelines

**wade.clearTimeout** _(timeoutUid)_

Cancel a timeout that was previously scheduled with _wade.setTimeout()_

**wade.cloneArray** _(array)_

Clone an array

**wade.cloneObject** _(object)_

Clone an object

**wade.createCanvas** _(resolutionFactor)_

Create an HTML5 canvas object and add it to the document

**wade.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.

**wade.createTransparentImage** _(imageName, width, height)_

Create a transparent image

**wade.deleteCanvases** _()_

Delete all the canvas objects created by WADE

**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 manually control when the drawing happens.

**wade.drawLayerToImage** _(layerId, imageName, replace, offset, transform, compositeOperation, callback)_

Draw a layer to an image in CPU memory

**wade.enableBatching** _(layerId, toggle)_

Turn Sprite batching on or off for a specific layer. Sprite batching is on by default.

**wade.enableGamepads** _(toggle)_

Enabled or disable gamepad support

**wade.enableMultitouch** _(toggle)_

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

**wade.error** _(data)_

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

**wade.expandBox** _(box1, box2)_

Expand box1 so that it encompasses both box1 and box2

**wade.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()

**wade.fadeInLayer** _(layerId, time, callback)_

Fade in a layer over time

**wade.fadeOutLayer** _(layerId, time, callback)_

Fade out a layer over time

**wade.findPath** _(parameters)_

Object  parameters : An object with the following properties:

**wade.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).

**wade.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.

**wade.forceRedraw** _(layerId)_

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

**wade.getActiveLayerIds** _()_

Get a list of the id's of all layers that are currently active (including empty ones)

**wade.getAppTime** _()_

Get the total simulation time, in seconds, since the app was started

**wade.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)

**wade.getBlur** _(layerId)_

Get the current strength of the blur effect on a specific layer

**wade.getCameraPosition** _()_

Get the current camera position.

**wade.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

**wade.getClockTime** _()_

Get the current system clock time in millisecond. The accuracy will vary depending on the system, an accurate performance timer is used where available.

**wade.getContainerHeight** _()_

Get the height of the window that contains the app

**wade.getContainerName** _()_

Get the name of the DIV or the HTML element that contains the App. This can be set when calling wade.init.

**wade.getContainerWidth** _()_

Get the width of the window that contains the app

**wade.getFont** _(file)_

Get the base64-encoded dataURL of a font

**wade.getForcedOrientation** _()_

Checks if the app is being displayed in forced orientation mode.

**wade.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 '//'

**wade.getGamepadData** _()_

Returns the current state of all gamepads.

**wade.getHostName** _(url)_

Get the host name based on a URL string

**wade.getImage** _(file, errorMessage)_

Get an image object that has previously been loaded, or a blank image

**wade.getImageData** _(file, posX, posY, width, height)_

Get the raw data of an image file or canvas, as an array of bytes

**wade.getImageDataURL** _(imageName)_

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

**wade.getJson** _(file)_

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

**wade.getKeyCode** _(keyName)_

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

**wade.getKeyName** _(keyCode)_

Get the key name associated with a numerical key code

**wade.getLayerCanvas** _(layerId)_

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

**wade.getLayerCustomProperties** _(layerId)_

Get the entire set of custom properties of a layer

**wade.getLayerCustomProperty** _(layerId, key)_

Retrieve the value of a custom property of a layer

**wade.getLayerDataURL** _(layerId)_

Generate a data URL from a game layer

**wade.getLayerOpacity** _(layerId)_

Get the opacity of a layer.

**wade.getLayerRenderMode** _(layerId)_

Get the current render mode of a layer.d

**wade.getLayerResolutionFactor** _(layerId)_

Get the resolution factor for a specific layer

**wade.getLayerSmoothing** _(layerId)_

Get the current image smoothing state for a specific layer

**wade.getLayerSorting** _(layerId)_

Get the sorting method that is currently being used for the layer

**wade.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

**wade.getLoadingStatus** _(file)_

Get the current loading status of a file

**wade.getMainLoop** _(name)_

Get the status of any main loop callback with the giving name

**wade.getMaxScreenHeight** _()_

Get the maximum height of the render area

**wade.getMaxScreenWidth** _()_

Get the maximum width of the render area

**wade.getMinScreenHeight** _()_

Get the minimum height of the render area

**wade.getMinScreenWidth** _()_

Get the minimum width of the render area

**wade.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

**wade.getObjectByName** _(name)_

Given a name, get the corresponding object, regardless of its type (it can be a SceneObject, a Path, a SceneObjectGroup, etc)

**wade.getObjectsInArea** _(area, layerId)_

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

**wade.getObjectsInScreenArea** _(area)_

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

**wade.getPath** _(name)_

Get a path, given its name as a string

**wade.getPaths** _(property, value)_

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

**wade.getPostProcessShader** _(layerId)_

Get the post process shader code being used by a layer

**wade.getPostProcessShaderUniforms** _(layerId)_

Get the post process shader uniforms being used by a layer

**wade.getProcessedTimelineEvent** _(eventId)_

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

**wade.getResolutionFactor** _()_

Get the current global resolution factor. Note that resolution factors of individual layers may be different, if they were set through setLayerResolutionFactor

**wade.getSceneObject** _(name)_

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

**wade.getSceneObjectGroup** _(name)_

Get a SceneObjectGroup, given its name as a string

**wade.getSceneObjectGroups** _(sceneObjects)_

Get all the SceneObjectGroups in the scene. Optionally apply a filter to only select groups that contain some specific objects.

**wade.getSceneObjectIndex** _(sceneObject)_

Get the current index of a scene object in the scene.

**wade.getSceneObjects** _(property, value)_

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

**wade.getScreenHeight** _()_

Get the hight of the current render area

**wade.getScreenWidth** _()_

Get the width of the current render area

**wade.getScript** _(file)_

Get the contents of a script file

**wade.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.

**wade.getSpritesInArea** _(area, layerId, sorted)_

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

**wade.getSpritesInScreenArea** _(area, sorted)_

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

**wade.getText** _(file)_

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

**wade.getTimelines** _()_

Get a reference to all the timelines, active and inactive. You can check the _active_ flag on each timeline to check its status.

**wade.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.

**wade.getWebAudioContext** _()_

If WebAudio is supported, get the current WebAudio context

**wade.getWindowMode** _()_

Get the current window mode.

**wade.hashString** _(str)_

Get a 32-bit integer hash of a given string

**wade.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.

**wade.init** _(appScript, appData, options)_

Initialize the engine

**wade.initializeApp** _()_

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

**wade.instanceApp** _()_

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

**wade.isAppInitialized** _()_

Checks whether the init function for the app has been executed

**wade.isArray** _(a)_

Check whether an object is an Array

**wade.isAutoLoadingImages** _()_

Check whether WADE is automatically trying to load images that haven't yet been loaded when the app is trying to use them.

**wade.isBatchingEnabled** _(layerId)_

Check if Sprite batching is currently enabled on a specific layer

**wade.isCameraMoving** _()_

Check if the camera is currently moving as a result of a previous call to wade.moveCamera

**wade.isDebugMode** _()_

Check whether we are currently running in debug mode

**wade.isEventListener** _(sceneObject, event)_

Check to see if a Scene Object is currently listening for a specific type of event

**wade.isKeyDown** _(keyCode)_

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

**wade.isMouseDown** _(buttonId)_

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

**wade.isMultitouchEnabled** _()_

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

**wade.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).

**wade.isUsingQuadtree** _(layerId)_

Check whether a layer is using quadtree-based optimizations

**wade.isWebAudioSupported** _()_

Checks whether the WebAudio API is supported by the client

**wade.isWebGlSupported** _()_

Check to see if WebGL is supported

**wade.loadAudio** _(file, autoplay, looping, callback, errorCallback)_

Load an audio file. Although the loading happens asynchronously, the simulation is suspended until this operation is completed.

**wade.loadFont** _(file, callback, errorCallback)_

Load a font file. Although the loading happens asynchronously, the simulation is suspended until this operation is completed.

**wade.loadImage** _(file, callback, errorCallback)_

Load an image file. Although the loading happens asynchronously, the simulation is suspended until this operation is completed.

**wade.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.

**wade.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.

**wade.loadPage** _(url)_

Open a web page in the app's window.

**wade.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

**wade.loadScript** _(file, callback, forceReload, errorCallback, dontExecute)_

Load a javascript file. Although the loading happens asynchronously, the simulation is suspended until this operation is completed.

**wade.loadText** _(file, objectToStoreData, callback, forceReload, errorCallback)_

Load a plain text file. Although the loading happens asynchronously, the simulation is suspended until this operation is completed.

**wade.log** _(data)_

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

**wade.mergeGlLayers** _(toggle)_

Define whether WebGL layers should be merged. When they are merged, each layer uses a separate render target, but they all share the same context. When layers are not merged, each layer gets its own separate gl context. By default layers are merged.

**wade.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.

**wade.orientedBoxContainsPoint** _(ob, point)_

Check whether an oriented box contains a point

**wade.orientedBoxIntersectsBox** _(ob, box)_

Check whether an axis-aligned box and an oriented box overlap each other.

**wade.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:

**wade.pauseSimulation** _(mainLoopName)_

Pause the simulation

**wade.playAudio** _(file, looping, callback)_

Play an audio file that has previously been loaded with a call to loadAudio or preloadAudio

**wade.playAudioSegment** _(file, start, end, callback)_

Play a segment of an audio file

**wade.postObject** _(url, object, callback, extraParameters)_

Send an object to a server. The object is serialized to JSON before being sent.

**wade.preloadAudio** _(file, autoplay, looping, callback, errorCallback)_

Load an audio file asynchronously, without suspending the simulation.

**wade.preloadFont** _(file, callback, errorCallback)_

Load a font file asynchronously, without suspending the simulation.

**wade.preloadImage** _(file, callback, errorCallback)_

Load an image file asynchronously, without suspending the simulation.

**wade.preloadJson** _(file, objectToStoreData, callback, forceReload, errorCallback)_

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

**wade.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

**wade.preloadScript** _(file, callback, forceReload, errorCallback, dontExecute)_

Load a javascript file asynchronously, without suspending the simulation.

**wade.preloadText** _(file, objectToStoreData, callback, forceReload, errorCallback)_

Load a plain text file asynchronously, without suspending the simulation.

**wade.preventIframe** _()_

Prevent the WADE App from being executed inside an iframe

**wade.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.

**wade.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()

**wade.recreateCanvases** _()_

Recreate canvas objects that were delete with a call to wade.deleteCanvases

**wade.removeEventListener** _(sceneObject, event)_

Unregister an object that has previously been registered to listen for an event using addEventListener.

**wade.removeGlobalEventListener** _(sceneObject, event)_

Unregister an object that has previously been registered to listen for an event using addGlobalEventListener.

**wade.removeLayer** _(layerId)_

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

**wade.removeObjectFromArray** _(object, array)_

Remove an object from an array

**wade.removeObjectFromArrayByIndex** _(index, array)_

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

**wade.removePath** _(path)_

Remove a Path from the scene

**wade.removeSceneObject** _(sceneObject)_

Remove a scene object from the scene

**wade.removeSceneObjectGroup** _(sceneObjectGroup)_

Remove a SceneObjectGroup from the scene

**wade.removeSceneObjects** _(sceneObjects)_

Remove multiple scene objects from the scene

**wade.removeUnusedLayers** _(exceptions)_

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

**wade.requireVersion** _(requiredVersion, errorMode, errorMessage)_

Ensure that the current version of WADE is greater or equal than a specific version.

**wade.restartInputEvents** _()_

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

**wade.resumeSimulation** _(mainLoopName)_

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

**wade.resumeTimeline** _(timelineId)_

Resume an inactive timeline

**wade.retrieveLocalObject** _(name)_

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

**wade.runFlowChart** _(flowChartData, startNode, precompile, delay, parentObject)_

Execute a flow chart

**wade.screenBoxToWorld** _(layerId, box)_

Transform a screen space box into world space

**wade.screenCapture** _(imageName, callback)_

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

**wade.screenDirectionToWorld** _(layerId, direction)_

Transform a screen space direction into world space

**wade.screenPositionToWorld** _(layerId, position)_

Transform a screen space position into world space

**wade.screenUnitToWorld** _(layerId)_

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

**wade.setAppTimerInterval** _(interval)_

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

**wade.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.

**wade.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

**wade.setBlur** _(layerId, blurAmount, time)_

Set the strength of the blur effect

**wade.setCameraBounds** _(minX, maxX, minY, maxY, minZ, maxZ)_

Force the camera position to be within the specified coordinate range. Omit or set any of the arguments to null to ignore specific boundaries. As a result, calling this function with no arguments effectively disables camera bounds.

**wade.setCameraPosition** _(pos)_

Set a world space position for the camera.

**wade.setCameraTarget** _(target, inertia, offset)_

Set a scene object for the camera to follow.

**wade.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.

**wade.setCatchUpBuffer** _(bufferTime)_

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

**wade.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.

**wade.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.

**wade.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.

**wade.setGlobalLoadingCallback** _(callback)_

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

**wade.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.

**wade.setInterval** _(f, time)_

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

**wade.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.

**wade.setLayer3DTransform** _(layerId, transformString, transformOrigin, time, callback)_

Set a CSS 3D transform on a layer. See [this MDN article](https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Using_CSS_transforms) for more details.

**wade.setLayerAlphaBlendMode** _(layerId, blendSrc, blendDest)_

Set a layer's alpha blend mode (for WebGL layers only, for 2d canvas layers this call has no effect)

**wade.setLayerColorBlendMode** _(layerId, blendSrc, blendDest)_

Set a layer's color blend mode (for WebGL layers only, for 2d canvas layers this call has no effect)

**wade.setLayerCustomProperties** _(layerId, properties)_

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

**wade.setLayerCustomProperty** _(layerId, key, value)_

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

**wade.setLayerOpacity** _(layerId, opacity)_

Set the opacity of a layer. For stand-alone canvas layers this is then applied to the layer canvas via CSS. For webgl layers, this is taken into account when drawing the layer's internal frame buffer onto the screen.

**wade.setLayerRenderMode** _(layerId, renderMode, options)_

Set the render mode for a layer

**wade.setLayerResolutionFactor** _(layerId, resolutionFactor)_

Set the resolution factor for a specific layer

**wade.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.

**wade.setLayerSorting** _(layerId, sortingType)_

Set the sorting method to use for a specified layer

**wade.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

**wade.setLoadingBar** _(visible, position, backColor, foreColor)_

Display (or hide) a progress bar that indicates the current loading progress

**wade.setLoadingImages** _(files, link)_

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

**wade.setMainLoop** _(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).

**wade.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.

**wade.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.

**wade.setMinimumInputEventInterval** _(type, interval)_

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

**wade.setPostProcessShader** _(layerId, shaderSource, shaderUniforms)_

Set a post-process shader for a layer

**wade.setResolutionFactor** _(\_resolutionFactor)_

Set the resolution factor for all layers

**wade.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().

**wade.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.

**wade.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.

**wade.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.

**wade.setSwipeTolerance** _(tolerance, numSamples)_

Set the tolerance for swipe events.

**wade.setText** _(file, data, setForPreloader)_

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

**wade.setTimeout** _(f, time)_

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

**wade.setWindowMode** _(mode)_

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

**wade.simulateSceneObject** _(sceneObject, toggle)_

Enable or disable the simulation of a scene object

**wade.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

**wade.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.

**wade.startTimeline** _(timeline, time, timelineId)_

Start a timeline. A timeline is a series of events, each associated with some code to execute and a time (in seconds) since the start of the timeline.

**wade.stop** _()_

Stop the execution of the WADE app. The simulation and rendering loops will be interrupted, and 'onAppTimer' events will stop firing.

**wade.stopAudio** _(uid)_

Stop an audio file that was playing

**wade.stopCamera** _()_

Stop any ongoing camera movement

**wade.stopInputEvents** _()_

Stop listening for input events

**wade.stopTimeline** _(timelineId)_

Stop an active timeline

**wade.storeLocalObject** _(name, object)_

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

**wade.unloadAllAudio** _()_

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

**wade.unloadAllImages** _()_

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

**wade.unloadAudio** _(file)_

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

**wade.unloadImage** _(file)_

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

**wade.unpackSpriteSheet** _(spriteSheet, destinations, numCellsX, numCellsY, unload)_

Create a separate image (more specifically an off-screen canvas) for each sprite in the sprite sheet

**wade.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.

**wade.warn** _(data)_

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

**wade.whitelistReferrers** _(domains)_

Only allow the App to be linked only from selected domains

**wade.worldBoxToCanvas** _(layerId, box)_

Transform a world space box into canvas space

**wade.worldBoxToScreen** _(layerId, box)_

Transform a world space box into screen space

**wade.worldDirectionToCanvas** _(layerId, direction)_

Transform a world space direction into canvas space

**wade.worldDirectionToScreen** _(layerId, direction)_

Transform a world space direction into screen space

**wade.worldPositionToCanvas** _(layerId, position)_

Transform a world space position into canvas space

**wade.worldPositionToScreen** _(layerId, position)_

Transform a world space position into screen space

**wade.worldUnitToCanvas** _(layerId)_

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

**wade.worldUnitToScreen** _(layerId)_

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

# Constructor Details

Wade

^

# Fields Details

**wade.app**

The current app instance

^

**wade.c\_timeStep**

The time (in seconds) between simulation steps

^

**wade.defaultLayer**

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

^

# Function Details

**wade.addEventListener** _(sceneObject, event)_

When input events (such as onClick) occur outside the bounding boxes of the objects' sprites, the scene object will not receive the event.

SceneObject  sceneObject : A scene object that will be listening for the event

string  event : The name of the event to listen for

^

**wade.addGlobalEventListener** _(sceneObject, event)_

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

SceneObject  sceneObject : A scene object that will be listening to the event

string  event : The name of the event to listen for

^

**wade.addPath** _(path)_

Add a Path to the scene

Path  path : The path to add to the scene

^

**wade.addSceneObject** _(sceneObject, autoListen, params)_

Add a scene object to the scene

SceneObject  sceneObject : The scene object to add to the scene

boolean  autoListen  (optional): This is true by default (if omitted), unless explicitly set to false or a falsy value. When it is true, WADE will set the object to automatically listen for any events for which handlers are defined on the object or any of its behaviors.

For example if the object has an onMouseDown function when it's added to the scene (or any of its behaviours has an onMouseDown function) and this parameter is true, the object will be set to listen for onMouseDown events automatically.

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, or null if it wasn't possible to add the object to the scene (due to constraints like grid type and coordinates)

^

**wade.addSceneObjectGroup** _(sceneObjectGroup)_

Add a SceneObjectGroup to the scene

SceneObjectGroup  sceneObjectGroup : The scene object group to add to the scene

^

**wade.ajax** _(params)_

Perform an asynchronous HTTP request

Object  params : An object with the following fields - only 'url' is mandatory:

url: string

type: string (either 'GET' or 'POST')

cache: boolean (defaults to true - set it to false to ensure you don't get a cached result)

dataType: string (set to 'json' to get the response as a JSON object)

success: function (a callback to execute when a successful response has been received - the response data is passed to the callback)

contentType: string (a Content-Type)

error: function (a callback to execute if the request fails - any data that was received, such as an incomplete response, is passed to the callback)

^

**wade.alwaysUpdateBlur** _(layerId, toggle)_

Force an update of the blur texture for a specific layer even when the blur amount is set to 0 for that layer

number  layerId  (optional): The layer id. If omitted or null, this will be applied to all currently active layers.

boolean  toggle  (optional): Whether the blur texture should always be updated. If this parameter is omitted it is assumed to be true.

^

**wade.areGamepadsSupported** _()_

Check to see if gamepads are supported in the current browser

Returns boolean : Whether gamepads are supported in the current browsers

^

**wade.areGlLayersMerged** _()_

Check whether WebGL layers are currently merged (i.e. they share the same context where possible). See mergeGlLayers for details.

Returns boolean : Whether WebGL layers are currently merged

^

**wade.autoLoadImages** _(toggle)_

boolean  toggle  (optional): Whether to auto-load images or not. If omitted this is assumed to be true.

^

**wade.blacklistReferrers** _(domains)_

Do not allow the App to be linked from selected domains

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

^

**wade.boxContainsBox** _(box1, box2)_

Check whether box1 contains box2

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

^

**wade.boxContainsPoint** _(box, point)_

Check whether a box contains a point

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

^

**wade.boxIntersectsBox** _(box1, box2)_

Check whether box1 and box2 intersect each other

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

^

**wade.boxIntersectsOrientedBox** _(box, ob)_

Check whether an axis-aligned box and an oriented box overlap each other.

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}

^

**wade.cancelInputEvents** _(toggle)_

boolean  toggle  (optional): Whether to cancel the normal handling of event. If this parameter is omitted, it's assumed to be true.

^

**wade.canvasBoxToWorld** _(layerId, box)_

Transform a canvas space box into world space

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

^

**wade.canvasDirectionToWorld** _(layerId, direction)_

Transform a canvas space direction into world space

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

^

**wade.canvasPositionToWorld** _(layerId, position)_

Transform a canvas space position into world space

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

^

**wade.canvasUnitToWorld** _(layerId)_

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

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

^

**wade.clampBoxToBox** _(box1, box2)_

Resize box1 so that it's fully contained in box2

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'

^

**wade.clearAllTimeoutsAndIntervals** _()_

Remove any active timeouts or intervals that have been set via _wade.setTimeout()_ or _wade.setInterval()_

Returns boolean : Whether any timeout or interval was active and was removed

^

**wade.clearCanvas** _(layerId)_

number  layerId : The id of the layer to clear

^

**wade.clearInterval** _(intervalUid)_

Cancel an interval that was previously scheduled with _wade.setInterval()_

number  intervalUid : The unique ID of the interval to cancel.

Returns boolean : Whether an active interval with the specified ID was found and removed

^

**wade.clearScene** _()_

Remove all the scene objects from the scene

^

**wade.clearTimelines** _()_

Stop and delete all timelines

^

**wade.clearTimeout** _(timeoutUid)_

Cancel a timeout that was previously scheduled with _wade.setTimeout()_

number  timeoutUid : The unique ID of the timeout to cancel.

Returns boolean : Whether an active timeout with the specified ID was found and removed

^

**wade.cloneArray** _(array)_

Clone an array

Array  array : The array to clone

Returns Array : A clone of the original array

^

**wade.cloneObject** _(object)_

Clone an object

Object  object : The object to clone

Returns Object : A clone of the original object

^

**wade.createCanvas** _(resolutionFactor)_

Create an HTML5 canvas object and add it to the document

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}

^

**wade.createPseudoArray** _(maxLength, onSet)_

Note that a pseudo-array only supports the \[\] operator, the length property and the push function. Other properties of Array are currently not supported.

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.

^

**wade.createTransparentImage** _(imageName, width, height)_

Create a transparent image

string  imageName : A name that identifies the new image. This can later be used by wade.getImage(imageName) and similar functions, or set as a source image of a Sprite or Animation.

Note that if an image with the same name exists, it will be replaced by the new transparent image.

number  width : The width of the image in pixels

number  height : The height of the image in pixels

^

**wade.deleteCanvases** _()_

Delete all the canvas objects created by WADE

^

**wade.draw** _(layerIds)_

number\|Array  layerIds  (optional): The id of the layer (or layers) to draw. If omitted, the whole scene will be drawn

^

**wade.drawLayerToImage** _(layerId, imageName, replace, offset, transform, compositeOperation, callback)_

Draw a layer to an image in CPU memory

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

function  callback  (optional): A function to execute when the image is ready

^

**wade.enableBatching** _(layerId, toggle)_

Turn Sprite batching on or off for a specific layer. Sprite batching is on by default.

number  layerId  (optional): The layer id. If omitted or null, batching will be enabled or disabled for all currently active layers.

boolean  toggle  (optional): Whether Sprite batching should be enabled. If this parameter is omitted it is assumed to be true.

^

**wade.enableGamepads** _(toggle)_

Enabled or disable gamepad support

boolean  toggle  (optional): Whether to enable or disable gamepad support. If omitted, this parameter is assumed to be true.

^

**wade.enableMultitouch** _(toggle)_

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

boolean  toggle  (optional): Whether to enable or disable multi touch. This parameter is true by default.

^

**wade.error** _(data)_

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

\\*  data : The data to log

^

**wade.expandBox** _(box1, box2)_

Expand box1 so that it encompasses both box1 and box2

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'

^

**wade.exportScene** _(stringify, exclude, exportObjectFunctions)_

boolean  stringify  (optional): Whether the result should be serialized to a JSON string

Array  exclude  (optional): An array of scene objects, paths and groups (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)

^

**wade.fadeInLayer** _(layerId, time, callback)_

Fade in a layer over time

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

^

**wade.fadeOutLayer** _(layerId, time, callback)_

Fade out a layer over time

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

^

**wade.findPath** _(parameters)_

Object  parameters : An object with the following properties:

start: {x: number, y: number}

target: {x: number, y: number}

collisionMap: \[\[\], \[\], ...\] a bi-dimensional array, where each truthy value represents a blocked tile on the map

boundaries (optional): {minX: number, minY: number, maxX: number, maxY: number}

movementOffsets (optional): \[{x: number, y: number}, {x: number, y: number}, ...\] An array of possible movement offsets. This can also be one of the following strings: 'straight', 'diagonal', 'both'

heightMap (optional): \[\[\], \[\], ...\] a bi-dimensional array with the height of each map tile; currently only used when maxStepHeight is not 0

maxStepHeight (optional): the maximum height difference between two tiles that will not block movement

maxPathLength (optional): the maximum length of the path that can be returned

Returns Array : An array of objects with x and y fields representing the tiles that make up the path from the starting point to the goal. Note that the starting point is not included. This may be an empty array if it wasn't possible to find a valid path.

^

**wade.forEachPixel** _(sourceImage, whatToDo, targetImage)_

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.

^

**wade.forceOrientation** _(orientation)_

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

^

**wade.forceRedraw** _(layerId)_

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

number  layerId  (optional): The id of the layer to redraw. If omitted or falsy, all layers will be redrawn.

^

**wade.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

^

**wade.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

^

**wade.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

^

**wade.getBlur** _(layerId)_

Get the current strength of the blur effect on a specific layer

number  layerId : The layer id

Returns number : The current strength of the blur effect

^

**wade.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

^

**wade.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

^

**wade.getClockTime** _()_

Get the current system clock time in millisecond. The accuracy will vary depending on the system, an accurate performance timer is used where available.

Returns number : The current system clock time

^

**wade.getContainerHeight** _()_

Get the height of the window that contains the app

Returns number : The height of the window that contains the app

^

**wade.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

^

**wade.getContainerWidth** _()_

Get the width of the window that contains the app

Returns number : The width of the window that contains the app

^

**wade.getFont** _(file)_

Get the base64-encoded dataURL of a font

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

^

**wade.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'

^

**wade.getFullPathAndFileName** _(file)_

string  file : The base file name

Returns string : The full path and file name

^

**wade.getGamepadData** _()_

Returns the current state of all gamepads.

Returns Array : An array listing all game pads. Each gamepad contains an axes and buttons array, allowing you to determine the exact state of each controller.

^

**wade.getHostName** _(url)_

Get the host name based on a URL string

string  url : The URL string

Returns string : The host name

^

**wade.getImage** _(file, errorMessage)_

Get an image object that has previously been loaded, or a blank image

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

^

**wade.getImageData** _(file, posX, posY, width, height)_

Get the raw data of an image file or canvas, as an array of bytes

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.

^

**wade.getImageDataURL** _(imageName)_

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

string  imageName : The name or virtual path of the image

Returns string : A base64 data URL

^

**wade.getJson** _(file)_

Returns object\|Array : The contents of the JSON file

^

**wade.getKeyCode** _(keyName)_

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

string  keyName : The key name

Returns number : The key code

^

**wade.getKeyName** _(keyCode)_

Get the key name associated with a numerical key code

number  keyCode : The key code

Returns string : The key name

^

**wade.getLayerCanvas** _(layerId)_

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

number  layerId  (optional): The id of the layer to use. Default is 1

Returns Object : An HTML5 canvas object

^

**wade.getLayerCustomProperties** _(layerId)_

Get the entire set of custom properties of a layer

number  layerId : The ID of the layer

Returns Object : An object containing all the custom properties

^

**wade.getLayerCustomProperty** _(layerId, key)_

Retrieve the value of a custom property of a layer

number  layerId : The ID of the layer

string  key : The name of the property to set

Returns \\* : The value of the property

^

**wade.getLayerDataURL** _(layerId)_

Generate a data URL from a game layer

number  layerId : The layer Id

Returns string : A base64 data URL

^

**wade.getLayerOpacity** _(layerId)_

Get the opacity of a layer.

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)

^

**wade.getLayerRenderMode** _(layerId)_

Get the current render mode of a layer.d

number  layerId : The id of the layer

Returns string : The layer render mode. This can be either '2d' or 'webgl'

^

**wade.getLayerResolutionFactor** _(layerId)_

Get the resolution factor for a specific layer

number  layerId : The layer id

Returns number : The resolution factor of the layer

^

**wade.getLayerSmoothing** _(layerId)_

Get the current image smoothing state for a specific layer

layerId : The layer id

Returns boolean : The image smoothing state for the specified layer

^

**wade.getLayerSorting** _(layerId)_

Get the sorting method that is currently being used for the layer

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'.

^

**wade.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

^

**wade.getLoadingStatus** _(file)_

Get the current loading status of a file

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

^

**wade.getMainLoop** _(name)_

Get the status of any main loop callback with the giving name

string  name : The name of the main loop

Returns {func: function, name: string, priority: number} : The status of the main loop callback, or null if no match is found

^

**wade.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

^

**wade.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

^

**wade.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

^

**wade.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

^

**wade.getMousePosition** _()_

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

^

**wade.getObjectByName** _(name)_

Given a name, get the corresponding object, regardless of its type (it can be a SceneObject, a Path, a SceneObjectGroup, etc)

string  name : The name of the object

Returns object : The object with the given name

^

**wade.getObjectsInArea** _(area, layerId)_

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

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 SceneObjectGroup : A SceneObjectGroup containing the SceneObjects in the area

^

**wade.getObjectsInScreenArea** _(area)_

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

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

Returns SceneObjectGroup : A SceneObjectGroup containing the SceneObjects in the area

^

**wade.getPath** _(name)_

Get a path, given its name as a string

string  name : The name of the path

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

^

**wade.getPaths** _(property, value)_

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

string  property  (optional): A property that must be set for the paths. Omit this parameter or use a falsy value to get all the paths in the scene.

\\*  value  (optional): The value that the property must be set to. You can omit this parameter to get all the paths where the property is defined, regardless of its value

Returns Array : An array containing references to all the paths that are currently present in the scene

^

**wade.getPostProcessShader** _(layerId)_

Get the post process shader code being used by a layer

number  layerId : The ID of the layer

^

**wade.getPostProcessShaderUniforms** _(layerId)_

Get the post process shader uniforms being used by a layer

number  layerId : The ID of the layer

Returns object : An object whose keys are uniform names and whose values are uniform types

^

**wade.getProcessedTimelineEvent** _(eventId)_

number  eventId  (optional, defaults to 0): The index of the event, e.g. use 0 for the first event that was processed

Returns Object : An object with a time parameter (a number) and a code parameter (a string)

^

**wade.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

^

**wade.getSceneObject** _(name)_

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

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

^

**wade.getSceneObjectGroup** _(name)_

Get a SceneObjectGroup, given its name as a string

string  name : The name of the SceneObjectGroup

Returns SceneObjectGroup : The SceneObjectGroup with the given name, or null if no scene object group with a matching name is in the scene

^

**wade.getSceneObjectGroups** _(sceneObjects)_

Get all the SceneObjectGroups in the scene. Optionally apply a filter to only select groups that contain some specific objects.

SceneObject\|Array  sceneObjects : If specified, restrict the result to groups that contain this SceneObject or this array of SceneObjects

Returns Array : An array of SceneObjectGroups

^

**wade.getSceneObjectIndex** _(sceneObject)_

Get the current index of a scene object in the scene.

SceneObject  sceneObject : The SceneObject

Returns number : The current index of the scene object in the scene

^

**wade.getSceneObjects** _(property, value)_

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

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 SceneObjectGroup : A SceneObjectGroup containing all the objects that are currently present in the scene and match the property-value filter

^

**wade.getScreenHeight** _()_

Get the hight of the current render area

Returns number : The height of the current render area

^

**wade.getScreenWidth** _()_

Get the width of the current render area

Returns number : The width of the current render area

^

**wade.getScript** _(file)_

Get the contents of a script file

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

^

**wade.getSmoothing** _()_

Returns boolean : The global image smoothing state

^

**wade.getSpritesInArea** _(area, layerId, sorted)_

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

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

^

**wade.getSpritesInScreenArea** _(area, sorted)_

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

object  area  (optional): An object with the following fields (in screen-space units): 'minX', 'minY', 'maxX', 'maxY'. If omitted, the full currently visible screen area is used.

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

^

**wade.getText** _(file)_

Returns string : The contents of the text file

^

**wade.getTimelines** _()_

Get a reference to all the timelines, active and inactive. You can check the _active_ flag on each timeline to check its status.

Returns object : An object where each field is a (named) timeline. See wade.startTimeline for a full description of the timeline data structure

^

**wade.getVersion** _()_

Returns string : The current version of WADE.

^

**wade.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.

^

**wade.getWindowMode** _()_

Get the current window mode.

Returns string : The current window mode.

^

**wade.hashString** _(str)_

Get a 32-bit integer hash of a given string

string  str : The string to hash

Returns number : The hash of the input string

^

**wade.importScene** _(data, loadingBar, callback, async, clearScene)_

object  data : A scene description object, such as one created with wade.exportScene(). The format is the following (all fields are optional):

{

**json**: An array of file names, describing which json files should be loaded. This can also be an array of objects in the format {resource: string, target: string} where _resource_ is the file to load, and the result is stored in wade.app\[ _target_\].

**text**: An array of file names, describing which text files should be loaded. This can also be an array of objects in the format {resource: string, target: string} where _resource_ is the file to load, and the result is stored in wade.app\[ _target_\].

**audio**: An array of audio file names

**scripts**: An array of script (.js) file names. Note that these scripts will be loaded and executed after the rest of the scene has been loaded, but before any scene objects are created and added to the scene

**images**: An array of image file names - you don't need to include files that are referenced by the scene objects and sprites in the scene (those will be loaded automatically).

**minScreenSize**: An object with x and y components describing the minimum screen size. Refer to the documentation of wade.setMinScreenSize() for more details

**maxScreenSize**: An object with x and y components describing the maximum screen size. Refer to the documentation of wade.setMaxScreenSize() for more details

**windowMode**: A string describing the window mode. Refer to the documentation of wade.setWindowMode() for more details

**orientation**: A string describing the orientation. Valid values are 'portrait' and 'landscape', all other values are ignored. See wade.forceOrientation() for more details

**sceneObjects**: An array containing all the SceneObjects to instantiate. See the SceneObject documentation for more details about the format to use for each object

**sceneObjectGroups**: An array containing SceneObjectGroups. See the SceneObjectGroup documentation for more details about the format to use for each group

**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

^

**wade.init** _(appScript, appData, options)_

Initialize the engine

string  appScript : Path and filename of the main app script

Object  \[appData : = {}\] An object containing initialization data for the app

Object  \[options : = {}\] An object that contains a set of fields that specify some configuration options. All the fields are optional. Supported values are:

**forceReload**: _boolean_ \- Whether to force reloading the main app script (as opposed to trying to get it from the cache. Defaults to false

**updateCallback**: _function_ \- A function to execute when an update for the cached version of the app is available and has been downloaded. This only applies to apps using the application cache. If omitted, the default behavior is to display an alert, after which the page will be refreshed.

**container**: _string_ \- The name of an HTML element in the current document (typically a DIV), that will contain all of the app's canvases and will be used to detect input events. Default is 'wade\_main\_div'.

**debug**: _boolean_ \- Whether to run the app in debug mode. When this is active, the source code of functions loaded through scene files will be easily accessible from the debugger. This will also inject 'sourceURL' tags into all dynamically loaded scripts. Defaults to false.

**audio**: _boolean_ \- Whether to activate audio or not. Defaults to true.

**input**: _boolean_ \- Whether to activate input or not. Defaults to true.

**forceWebGl**: _boolean_ \- Whether to use WebGl even when the browser detects potential performance problems. Defaults to false.

**globalUnderscore**: _boolean_ \- Whether to use the global **\_** variable to access scene objects. Defaults to true.

**audioContext**: _AudioContext_ \- An external WebAudio Context to use for all audio-related operations. If this is not specified, wade will create a new internal one.

^

**wade.initializeApp** _()_

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

^

**wade.instanceApp** _()_

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

^

**wade.isAppInitialized** _()_

Checks whether the init function for the app has been executed

^

**wade.isArray** _(a)_

Check whether an object is an Array

object  a : The object to test

Returns boolean : Whether the object is a JavaScript Array

^

**wade.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.

^

**wade.isBatchingEnabled** _(layerId)_

Check if Sprite batching is currently enabled on a specific layer

number  layerId : The layer id

Returns boolean : Whether Sprite batching is currently enabled

^

**wade.isCameraMoving** _()_

Check if the camera is currently moving as a result of a previous call to wade.moveCamera

Returns boolean : Whether tha camera is moving

^

**wade.isDebugMode** _()_

Check whether we are currently running in debug mode

Returns boolean : Whether we are currently running in debug mode

^

**wade.isEventListener** _(sceneObject, event)_

Check to see if a Scene Object is currently listening for a specific type of event

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

^

**wade.isKeyDown** _(keyCode)_

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

number\|string  keyCode : The code of the key to check (as a number), or a string representing a key name (for example 'left', 'space', 'x')

Returns boolean : Whether the key is pressed

^

**wade.isMouseDown** _(buttonId)_

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

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

^

**wade.isMultitouchEnabled** _()_

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

^

**wade.isScreenRotated** _()_

Returns : {boolean}

^

**wade.isUsingQuadtree** _(layerId)_

Check whether a layer is using quadtree-based optimizations

number  layerId : The id of the layer to check

Returns boolean : Whether the layer is using a quadtree

^

**wade.isWebAudioSupported** _()_

Checks whether the WebAudio API is supported by the client

Returns boolean : whether the WebAudio API is supported

^

**wade.isWebGlSupported** _()_

Check to see if WebGL is supported

Returns boolean : Whether WebGL is supported in the current environment

^

**wade.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.

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

^

**wade.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.

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

^

**wade.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.

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

^

**wade.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.

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

^

**wade.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.

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

^

**wade.loadPage** _(url)_

Open a web page in the app's window.

string  url : The address of the web page to open

^

**wade.loadScene** _(fileName, loadingBar, callback, clearScene)_

string  fileName : The name of a JSON file containing a description of the scene

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

^

**wade.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.

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.

^

**wade.loadText** _(file, objectToStoreData, callback, forceReload, errorCallback)_

Load a plain text file. Although the loading happens asynchronously, the simulation is suspended until this operation is completed.

If a loading screen has ben set, it will be shown during the loading.

See preloadText for an equivalent operation that happens in the background without suspending the simulation.

string  file : A text 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 text 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 text file cannot be loaded

^

**wade.log** _(data)_

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

\\*  data : The data to log

^

**wade.mergeGlLayers** _(toggle)_

Note that changing this at run time is expensive as it results in deletion and recreation of any gl contexts that may already exist.

Also note that only contiguous layers can be merged: inserting a 2d canvas layer between WebGL layers will prevent those layers from being merged.

boolean  toggle  (optional): Whether WebGL layers should be merged. If this parameter is omitted it is assumed to be true.

^

**wade.moveCamera** _(destination, speed, callback)_

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.

^

**wade.orientedBoxContainsPoint** _(ob, point)_

Check whether an oriented box contains a point

Object  ob : An object with 'centerX' and 'centerY' fields representing its center coordinates, and the following fields:

Object  point : An object with the following fields: 'x', 'y'

Returns boolean : Whether orientedBox contains point

^

**wade.orientedBoxIntersectsBox** _(ob, box)_

Check whether an axis-aligned box and an oriented box overlap each other.

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:

Returns : {boolean}

^

**wade.orientedBoxIntersectsOrientedBox** _(ob1, ob2)_

Object  ob1 : An oriented box

Object  ob2 : The other oriented box

Returns boolean : Whether the two boxes intersect each other

^

**wade.pauseSimulation** _(mainLoopName)_

Pause the simulation

string  mainLoopName  (optional): The name of the main loop that you want to pause. If omitted, the whole simulation will be paused.

^

**wade.playAudio** _(file, looping, callback)_

Play an audio file that has previously been loaded with a call to loadAudio or preloadAudio

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  (optional): 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

^

**wade.playAudioSegment** _(file, start, end, callback)_

Play a segment of an audio file

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

^

**wade.postObject** _(url, object, callback, extraParameters)_

Send an object to a server. The object is serialized to JSON before being sent.

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)

^

**wade.preloadAudio** _(file, autoplay, looping, callback, errorCallback)_

Load an audio file asynchronously, without suspending the simulation.

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

^

**wade.preloadFont** _(file, callback, errorCallback)_

Load a font file asynchronously, without suspending the simulation.

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

^

**wade.preloadImage** _(file, callback, errorCallback)_

Load an image file asynchronously, without suspending the simulation.

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

^

**wade.preloadJson** _(file, objectToStoreData, callback, forceReload, errorCallback)_

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

string  file : A json 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): 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

^

**wade.preloadScene** _(fileName, loadingBar, callback, clearScene)_

string  fileName : The name of a JSON file containing a description of the scene

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

^

**wade.preloadScript** _(file, callback, forceReload, errorCallback, dontExecute)_

Load a javascript file asynchronously, without suspending the simulation.

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.

^

**wade.preloadText** _(file, objectToStoreData, callback, forceReload, errorCallback)_

Load a plain text file asynchronously, without suspending the simulation.

string  file : A text 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): 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 text file cannot be loaded

^

**wade.preventIframe** _()_

Prevent the WADE App from being executed inside an iframe

^

**wade.processEvent** _(event, eventData)_

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.

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

^

**wade.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()

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.

^

**wade.recreateCanvases** _()_

Recreate canvas objects that were delete with a call to wade.deleteCanvases

^

**wade.removeEventListener** _(sceneObject, event)_

Unregister an object that has previously been registered to listen for an event using addEventListener.

SceneObject  sceneObject : The scene object to unregister

string  event : The name of the event to stop listening for

^

**wade.removeGlobalEventListener** _(sceneObject, event)_

Unregister an object that has previously been registered to listen for an event using addGlobalEventListener.

SceneObject  sceneObject : The scene object to unregister

string  event : The name of the event to stop listenening for

^

**wade.removeLayer** _(layerId)_

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

number  layerId : The id of the layer to remove

^

**wade.removeObjectFromArray** _(object, array)_

Remove an object from an array

Object  object : The object to remove from the array

Array  array : The array that contains the object

Returns Array : The array after the object has been removed

^

**wade.removeObjectFromArrayByIndex** _(index, array)_

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

number  index : The index of the object to remove

Array  array : The array that contains the object

Returns Array : The array after the object has been removed

^

**wade.removePath** _(path)_

Remove a Path from the scene

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

^

**wade.removeSceneObject** _(sceneObject)_

Remove a scene object from the scene

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.

^

**wade.removeSceneObjectGroup** _(sceneObjectGroup)_

Remove a SceneObjectGroup from the scene

SceneObjectGroup\|string  sceneObjectGroup : The scene object group to be removed from the scene, or its name as a string

^

**wade.removeSceneObjects** _(sceneObjects)_

Remove multiple scene objects from the scene

Array\|SceneObjectGroup  sceneObjects : An array of scene objects to remove from the scene

^

**wade.removeUnusedLayers** _(exceptions)_

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

Array  exceptions  (optional): An array of layer id's that you do NOT want to remove even if unused

^

**wade.requireVersion** _(requiredVersion, errorMode, errorMessage)_

Ensure that the current version of WADE is greater or equal than a specific version.

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;.

^

**wade.restartInputEvents** _()_

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

^

**wade.resumeSimulation** _(mainLoopName)_

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

string  mainLoopName  (optional): The name of the main loop that you want to resume. If omitted, the whole simulation will be resumed.

^

**wade.resumeTimeline** _(timelineId)_

Resume an inactive timeline

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

^

**wade.retrieveLocalObject** _(name)_

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

string  name : The name of the object to retrieve

^

**wade.runFlowChart** _(flowChartData, startNode, precompile, delay, parentObject)_

Execute a flow chart

object  flowChartData : This is an object that contains a set of boxes. Each property of this object is the unique id of a box. Each box is itself an object with the following properties:

uid: string - a unique identifier for the box

children: object - an object where each property name represents a condition, and each property value is the uid of another box in the chart

title: string

code: string - the code to execute for the box. This code can call this.next(condition) to advance to the next box. It is possible to call this.next() without arguments to simply go to the first child in the list of children. Note that moving from one box to the next is an asynchronous process.

startNode: boolean
Whether this is a starting node

string  startNode  (optional): The title or the uid of the starting box. If omitted or null, the entire data is scanned to find a box with the startNode flag. When that fails, the first box is used as a start node.

boolean  precompile  (optional): Whether the code for all boxes should be compiled when runFlowChart is called, as opposed to compiling each function as it is needed. This is true by default.

number  delay  (optional, defaults to 0): How many milliseconds to wait when moving from one box to the next

SceneObject  parentObject  (optional): The owner of the flow chart. This determines the context (i.e. the meaning of the _this_ keyword) for the flow chart functions.

Returns object : An object that contains data about the current state of the flow chart, as follows:

startTime: number - when the flow chart was executed. This is a number in seconds relative to the starting point of the wade app

flowChartData: object - a copy of the data that is passed in as the first argument to this function

visitedNodes: array - a list of the uid's of all the nodes that have been visited so far

running: boolean - whether the flow chart is still executing

^

**wade.screenBoxToWorld** _(layerId, box)_

Transform a screen space box into world space

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

^

**wade.screenCapture** _(imageName, callback)_

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

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

function  callback  (optional): A function to execute when the image is ready

^

**wade.screenDirectionToWorld** _(layerId, direction)_

Transform a screen space direction into world space

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

^

**wade.screenPositionToWorld** _(layerId, position)_

Transform a screen space position into world space

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

^

**wade.screenUnitToWorld** _(layerId)_

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

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

^

**wade.setAppTimerInterval** _(interval)_

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

number  interval : The number of seconds between 'onAppTimer' events

^

**wade.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.

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.

^

**wade.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

String  path : the base path of the app

^

**wade.setBlur** _(layerId, blurAmount, time)_

Set the strength of the blur effect

number  layerId  (optional): The layer id. If omitted or null, the same value will be applied to all currently active layers.

number  blurAmount  (optional, defaults to 0): The strength of the blur effeft. Typically this is a number between 0 (no blur) and 1 (full blur)

number  time  (optional, defaults to 0): How long the transition to the new blur level should last (in seconds)

^

**wade.setCameraBounds** _(minX, maxX, minY, maxY, minZ, maxZ)_

Note that this takes priority over other camera functions such as wade.setCameraTarget() or wade.moveCamera()

number  minX  (optional): The minimum value for the camera's X axis

number  maxX  (optional): The maximum value for the camera's X axis

number  minY  (optional): The minimum value for the camera's Y axis

number  maxY  (optional): The maximum value for the camera's Y axis

number  minZ  (optional): The minimum value for the camera's Z axis

number  maxZ  (optional): The maximum value for the camera's Y axis

^

**wade.setCameraPosition** _(pos)_

Set a world space position for the camera.

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

^

**wade.setCameraTarget** _(target, inertia, offset)_

Set a scene object for the camera to follow.

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.

^

**wade.setCanvasClearing** _(layerId, toggle)_

number  layerId : The layer id

boolean  toggle : Whether to clear the canvas between frames

^

**wade.setCatchUpBuffer** _(bufferTime)_

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

number  bufferTime : The buffer time, in seconds

^

**wade.setClickTolerance** _(tolerance)_

number  tolerance  (optional): The tolerance for "onClick" events, in pixels.

^

**wade.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.

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.

^

**wade.setFullScreen** _(toggle)_

boolean  toggle  (optional): Whether to enable or disable full screen mode. If not specified, "true" is assumed.

^

**wade.setGlobalLoadingCallback** _(callback)_

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

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

^

**wade.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.

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.

^

**wade.setInterval** _(f, time)_

function  f : A function to execute periodically

number  time : The app simulation time, in milliseconds, to wait between function calls

Returns number : A unique ID that can be used to cancel the interval via _wade.clearInterval()_

^

**wade.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.

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.

^

**wade.setLayer3DTransform** _(layerId, transformString, transformOrigin, time, callback)_

Set a CSS 3D transform on a layer. See [this MDN article](https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Using_CSS_transforms) for more details.

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

^

**wade.setLayerAlphaBlendMode** _(layerId, blendSrc, blendDest)_

Set a layer's alpha blend mode (for WebGL layers only, for 2d canvas layers this call has no effect)

number  layerId : The id of the layer

string  blendSrc : The source alpha blend value. Default is 'SRC\_ALPHA'. All WebGl color blending constant names can be used here (e.g. DST\_ALPHA, ONE\_MINUS\_SRC\_ALPHA, etc)

string  blendDest : The destination alpha blend value. Default is 'ONE\_MINUS\_SRC\_ALPHA'. All WebGl color blending constant names can be used here (e.g. DST\_ALPHA, ONE\_MINUS\_SRC\_ALPHA, etc)

^

**wade.setLayerColorBlendMode** _(layerId, blendSrc, blendDest)_

Set a layer's color blend mode (for WebGL layers only, for 2d canvas layers this call has no effect)

number  layerId : The id of the layer

string  blendSrc : The source color blend value. Default is 'ONE'. All WebGl color blending constant names can be used here (e.g. DST\_COLOR, ONE\_MINUS\_SRC\_COLOR, etc)

string  blendDest : The destination color blend value. Default is 'ONE\_MINUS\_SRC\_ALPHA'. All WebGl color blending constant names can be used here (e.g. DST\_COLOR, ONE\_MINUS\_SRC\_COLOR, etc)

^

**wade.setLayerCustomProperties** _(layerId, properties)_

@param layerId

@param properties

^

**wade.setLayerCustomProperty** _(layerId, key, value)_

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

number  layerId : The ID of the layer

string  key : The name of the property to set

\\*  value  (optional): The value of the property

^

**wade.setLayerOpacity** _(layerId, opacity)_

number  layerId : The id of the layer

number  opacity : The opacity of the layer, between 0 (fully transparent) and 1 (fully opaque)

^

**wade.setLayerRenderMode** _(layerId, renderMode, options)_

Set the render mode for a layer

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.

^

**wade.setLayerResolutionFactor** _(layerId, resolutionFactor)_

Set the resolution factor for a specific layer

number  layerId : The layer id

number  resolutionFactor : The resolution factor. It must be > 0. 1 indicates full resolution, < 1 lower resolution, > 1 higher resolution.

^

**wade.setLayerSmoothing** _(layerId, toggle)_

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.

^

**wade.setLayerSorting** _(layerId, sortingType)_

Set the sorting method to use for a specified layer

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

^

**wade.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

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.

^

**wade.setLoadingBar** _(visible, position, backColor, foreColor)_

Display (or hide) a progress bar that indicates the current loading progress

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

^

**wade.setLoadingImages** _(files, link)_

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

string\|Array  files : An image file name, or an array of image file names. These images don't need to be loaded using loadImage

string  link  (optional): An URL to open when the loading image is clicked. The link is opened in a new window (or tab).

^

**wade.setMainLoop** _(callback, name, priority)_

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 setMainLoop() 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 descending order of priority. Default is 0

^

**wade.setMaxScreenSize** _(width, height)_

The default values are 1920 and 1080

number  width : The maximum width of the render area

number  height : The maximum height of the render area

^

**wade.setMinScreenSize** _(width, height)_

The default values are 0 and 0

number  width : The minimum width of the render area

number  height : The minimum height of the render area

^

**wade.setMinimumInputEventInterval** _(type, interval)_

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

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

^

**wade.setPostProcessShader** _(layerId, shaderSource, shaderUniforms)_

Set a post-process shader for a layer

number  layerId : The ID of the layer

string  shaderSource  (optional): The contents of a "main(void)" fragment shader function. If omitted or empty, the default pixel shader is used, resulting in no post-processing.

string  shaderUniforms  (optional): An object that specifies the name and type of custom shader uniforms that you want to use. For example {tintColor: 'vec4'}. Values will be retrieved from public properties of the Sprite using the same name. So in this example, make sure that your sprite has got a property called tintColor that is an array with 4 elements. Supported types are currently: float, vec2, vec3, vec4, int, ivec2, ivec3, ivec4 and sampler2D.

^

**wade.setResolutionFactor** _(\_resolutionFactor)_

Set the resolution factor for all layers

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

^

**wade.setSceneObjectIndex** _(sceneObject, index)_

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.

^

**wade.setScreenSize** _(width, height)_

number  width : The width of the render area

number  height : The height of the render area

^

**wade.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.

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.

^

**wade.setSmoothing** _(toggle)_

boolean  toggle  (optional): Whether to enable or disable image smoothing. If not specified, "true" is assumed.

^

**wade.setSwipeTolerance** _(tolerance, numSamples)_

Set the tolerance for swipe events.

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.

^

**wade.setText** _(file, data, setForPreloader)_

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

string  file : The text file name

string  data  (optional): The data object to associate with the text 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.preloadText will get this cached version of the data instead of loading it again in the background.

^

**wade.setTimeout** _(f, time)_

function  f : A function to execute

number  time : The app simulation time, in milliseconds, to wait until the function is executed

Returns number : A unique ID that can be used to cancel the timeout via _wade.clearTimeout()_

^

**wade.setWindowMode** _(mode)_

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

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'

^

**wade.simulateSceneObject** _(sceneObject, toggle)_

Enable or disable the simulation of a scene object

SceneObject  sceneObject : The scene object

boolean  toggle : Whether to enable the simulation

^

**wade.siteLock** _(domain)_

string  domain : The domain where you want the WADE App to be executed. For example 'www.clockworkchilli.com'

^

**wade.skipMissedFrames** _()_

^

**wade.startTimeline** _(timeline, time, timelineId)_

Start a timeline. A timeline is a series of events, each associated with some code to execute and a time (in seconds) since the start of the timeline.

The reference time can be either the app's simulation time, or the system clock, and can be set in _timeline.referenceTime_. Please consider how you want variable framerate to affect your timing when you choose a value for this. Note that code won't be execute while the simulation isn't running, regardless of the type of referenceTime. However, the app time is paused while the simulation is paused, the clock time is not.

Object  timeline : A timeline object with the following structure:

```

{

referenceTime: string (it can be either 'app' or 'clock' - if unspecified, it defaults to 'app')

events: [{time: number, code: string}, {time: number, code: string}]

}

```

number  time  (optional, defaults to 0): The starting point of the timeline

string  timelineId  (optional): The ID of an existing timeline that you want to replace. If null or unspecified, a new timeline will be created

Returns string : The id of the new timeline. This can be used to call wade.stopTimeline() and wade.resumeTimeline()

^

**wade.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.

^

**wade.stopAudio** _(uid)_

Stop an audio file that was playing

number  uid  (optional): The unique identifier of the audio source that you want to stop playing. If omitted, all sources will be stopped

^

**wade.stopCamera** _()_

Stop any ongoing camera movement

^

**wade.stopInputEvents** _()_

Stop listening for input events

^

**wade.stopTimeline** _(timelineId)_

Stop an active timeline

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

^

**wade.storeLocalObject** _(name, object)_

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

string  name : The name to give the object. This can later be used with a call to retrieveLocalObject

object\|Array  object : The object to store

^

**wade.unloadAllAudio** _()_

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

^

**wade.unloadAllImages** _()_

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

^

**wade.unloadAudio** _(file)_

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

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

^

**wade.unloadImage** _(file)_

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

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

^

**wade.unpackSpriteSheet** _(spriteSheet, destinations, numCellsX, numCellsY, unload)_

Create a separate image (more specifically an off-screen canvas) for each sprite in the sprite sheet

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, defaults to 1): The number of horizontal cells

number  numCellsY  (optional, defaults to 1): The number of vertical cells

boolean  unload  (optional): Whether to unload the sprite sheet after unpacking

^

**wade.useQuadtree** _(layerId, toggle)_

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.

^

**wade.warn** _(data)_

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

\\*  data : The data to log

^

**wade.whitelistReferrers** _(domains)_

Only allow the App to be linked only from selected domains

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

^

**wade.worldBoxToCanvas** _(layerId, box)_

Transform a world space box into canvas space

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

^

**wade.worldBoxToScreen** _(layerId, box)_

Transform a world space box into screen space

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

^

**wade.worldDirectionToCanvas** _(layerId, direction)_

Transform a world space direction into canvas space

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

^

**wade.worldDirectionToScreen** _(layerId, direction)_

Transform a world space direction into screen space

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

^

**wade.worldPositionToCanvas** _(layerId, position)_

Transform a world space position into canvas space

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

^

**wade.worldPositionToScreen** _(layerId, position)_

Transform a world space position into screen space

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

^

**wade.worldUnitToCanvas** _(layerId)_

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

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

^

**wade.worldUnitToScreen** _(layerId)_

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

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

^
