Constructors

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)

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

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

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)

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

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)

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.

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)

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.

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)

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.

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)

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

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)

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.

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)

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

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)

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

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)

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.

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)

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

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)


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


Returns object|Array : The contents of the JSON file

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

Get the current mouse position, or the position of the last input event (in the case of touch events). Note that if there have been no mouse or input events since the app started, this will return an empty object

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

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

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

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

Get the "global" image smoothing state. This is the image smoothing state that is applied to all the layers, unless setLayerSmoothing has been called for some specific layers.

Returns boolean : The global image smoothing state

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


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


Returns string : The contents of the text file

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

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

Returns string : The current version of WADE.

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

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.

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

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

    Returns : {boolean}

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

    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

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


    {position: {x: number, y: number}, foreColor: string, backColor: string} loadingBar (optional): A loading bar while loading the assets referenced in the scene data (see wade.setLoadingBar for details about the parameters, which are all optional). If omitted or falsy, no loading bar will be shown


    function callback (optional): A function to execute when the scene has been loaded


    boolean clearScene (optional): Whether the previous scene should be cleared before adding objects for the new scene. False by default

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

    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.

    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)

    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.

    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:

    'axisXx' and 'axisXy' represent the rotated X axis (the Width axis) of the rectangle in world-space coordinates. The length of the axisX vector must be half the width of the rectangle.

    'axisYx' and 'axisYy' represent the rotated Y axis (the Height axis) of the rectangle in world-space coordinates. The length of the axisY vector must be half the height of the rectangle.

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


    Returns boolean : Whether orientedBox contains point

    ^
    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:

    '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.orientedBoxIntersectsOrientedBox (ob1, ob2)

    Check whether two oriented boxes intersect each other. Each box must be an object with 'centerX' and 'centerY' fields representing its center coordinates, and the following fields:

    'axisXx' and 'axisXy' represent the rotated X axis (the Width axis) of the rectangle in world-space coordinates. The length of the axisX vector must be half the width of the rectangle.

    'axisYx' and 'axisYy' represent the rotated Y axis (the Height axis) of the rectangle in world-space coordinates. The length of the axisY vector must be half the height of the rectangle.

    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


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


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

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


    {position: {x: number, y: number}, foreColor: string, backColor: string} loadingBar (optional): A loading bar while loading the assets referenced in the scene data (see wade.setLoadingBar for details about the parameters, which are all optional). If omitted or falsy, no loading bar will be shown


    function callback (optional): A function to execute when the scene has been loaded


    boolean clearScene (optional): Whether the previous scene should be cleared before adding objects for the new scene. False by default

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


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

    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)

    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.

    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)

    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.

    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)

    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.

    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)

    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.

    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)

    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.

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

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

    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.

    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)

    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.

    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)

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

    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)

    Set the maximum width and height of the render area. When the window mode is set to full, even when the render area is automatically resized it will never be larger than the specified dimensions.

    The default values are 1920 and 1080

    number width : The maximum width of the render area


    number height : The maximum height of the render area

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

    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)

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

    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)

    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.

    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)

    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.

    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)

    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.

    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)

    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

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

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

    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)

    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.

    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

    ^