Constructors
- Animation
- IsoCharacter
- Path
- PhysicsObject
- SceneObject
- SceneObjectGroup
- Sprite
- TextSprite
- TilemapCharacter
- wade
- wade.drawFunctions
- wade.iso
- wade.physics
- wade.tilemap
- wade.vec2
Sprite
Constructor Summary
Sprite
A Sprite object is used to display images. It may have references to Animation objects if the image to display is supposed to be animating.
Functions Summary
Sprite.addAnimation (name, animation, dontPlay)
Add an animation to the sprite. If, after this operation, there is only one animation for this sprite, it will be played automatically
Sprite.alwaysDraw (toggle)
Force a sprite to get drawn every frame, disabling potential optimizations. This does not happen by default, i.e. drawing optimizations are enabled by default.
Sprite.bringToFront ()
Bring the sprite to the front of its layer. Note that if any sorting function (other than 'none') has been specified for the layer, when the sorting occurs it will override this operation
Sprite.cache ()
Draw this sprite to an off-screen canvas, then use this canvas as a source image whenever this sprite needs to be drawn again
Sprite.clone ()
Clone the sprite
Sprite.containsScreenPoint (point)
Check whether the sprite contains a given screen space point
Sprite.drawToImage (virtualPath, replace, offset, transform, compositeOperation, renderMode)
Draw a sprite to an image associated with a virtual path. The image will be stored in CPU memory. To create a WebGL texture in GPU memory, use Sprite.drawToTexture instead.
Sprite.drawToTexture (gpuTextureName, cpuTextureName)
Draw the sprite to a WebGL texture in GPU memory. Note that this is only possible if the sprite is currently on a WebGL layer.
Sprite.fadeIn (time, callback)
Fade in effect, gradually changing the opacity (alpha) of the sprite from 0 to 1. If the sprite is invisible, it is set to visible before fading in.
Sprite.fadeOut (time, callback)
Fade out effect, gradually changing the opacity (alpha) of the sprite from 1 to 0. After fading out, the sprite is set to invisible.
Sprite.getAllImageNames ()
Get the names of all images being used by this sprite and its animations
Sprite.getAlphaThreshold ()
Check whether the Sprite is using pixel-perfect mouse events, i.e. whether it discards mouse events on transparent pixels
Sprite.getAnimation (name)
Get the animation object associated with a given animation name
Sprite.getCurrentAnimation ()
Get the active animation object for the sprite
Sprite.getCurrentAnimationName ()
Get the name of the active animation for the sprite
Sprite.getDrawFunction ()
Get the current draw function of the sprite
Sprite.getDrawModifiers ()
Get the current modifiers that are applied to the sprite
Sprite.getImageArea ()
Get the area of the source image (expressed as a fraction of the source image size) that is being used to draw this sprite. If this wasn't modified with setImageArea(), by default the sprite uses the full image from (0, 0) to (1, 1).
Sprite.getImageName ()
Get the name of the image being used
Sprite.getIndexInLayer ()
Get the index of the sprite in its layer. For unsorted layers this matches the order in which the sprites were added to the layers, though for layers with sorting this may change every frame accoring to the sorting criterion.
Sprite.getLayerId ()
Get the id of the sprite's layer
Sprite.getName ()
Get the current name of this sprite, if it was set with Sprite.setName()
Sprite.getOverlappingObjects (searchAllLayers, precision)
Get an array of objects overlapping this sprite
Sprite.getPixelShader ()
Get the source code of the current pixel shader function for this sprite
Sprite.getPixelShaderUniforms ()
Get a list of the custom shader uniforms for this sprite.
Sprite.getPosition ()
Get the world space position of the sprite
Sprite.getRotation ()
Get the current rotation angle of the sprite
Sprite.getScaleFactor ()
Get the current scale factor of the sprite, that is its size compared to the source image (or animation frame) size
Sprite.getSceneObject ()
Get the parent scene object for this sprite (if any)
Sprite.getScreenBoundingBox ()
Get the bounding box of the Sprite in screen space
Sprite.getScreenPositionAndExtents ()
Get the screen space position and extents for this sprite
Sprite.getSize ()
Get the world space size of the sprite
Sprite.getSortPoint ()
Get the sprite's sort point that is used in the calculations to determine whether the sprite should appear in front of other sprites in the same layer, according to the layer's sorting mode.
Sprite.getWorldOffset (screenPosition)
Convert a screen space position into a world space offset relative to the sprite's world space position
Sprite.hasAnimation (name)
Check whether the sprite has an animation that matches the given name
Sprite.isAlwaysDrawing ()
Check whether a sprite is being forcefully drawn every frame
Sprite.isOnScreen ()
Check whether the Sprite is currently visible on the screen
Sprite.isUsingPixelPerfectMouseEvents ()
Check whether the Sprite is using pixel-perfect mouse events, i.e. whether it discards mouse events on transparent pixels
Sprite.isVisible ()
Check whether the sprite is visible
Sprite.overlapsSprite (otherSprite, precision)
Test to see whether this sprite overlaps another sprite
Sprite.playAnimation (name, direction)
Play an animation for this sprite
Sprite.pushToBack ()
Send the sprite to the back of its layer. Note that if any sorting function (other than 'none') has been specified for the layer, when the sorting occurs it will override this operation
Sprite.putBehindSprite (otherSprite)
Move the sprite behind another sprite in the same layer. Note that if any sorting function (other than 'none') has been specified for the layer, when the sorting occurs it will override this operation
Sprite.resumeAnimation ()
Resume playing an animation that had been stopped
Sprite.serialize (stringify, propertiesToExclude)
Export this sprite to an object that can then be used to create a new sprite like this one (by passing the resulting object to the Sprite constructor).
Sprite.setDirtyArea ()
Mark the area occupied by the sprite as dirty. Depending on the sprite's layer's properties, this operation may cause this and some other sprites to be redrawn for the next frame
Sprite.setDrawFunction (drawFunction)
Set a custom draw function for the sprite
Sprite.setDrawModifiers (modifiers)
Set draw modifiers for this sprite.
Sprite.setImageArea (minX, minY, maxX, maxY)
Set the area of the source image that should be used to draw this sprite. Numbers should be between 0 and 1, representing a fraction of the source image size.
Sprite.setImageFile (image, updateSizeFromImage)
Set an image to use with the current sprite
Sprite.setIndexInLayer (index)
Set the sprite's index in its layer.
Sprite.setLayer (layerId)
Set a new layer for the sprite
Sprite.setName (name)
Set a name for the sprite
Sprite.setPixelShader (shaderSource, shaderUniforms)
Set a custom pixel shader for this sprite.
Sprite.setPosition (positionX, positionY)
Set the world space position of the sprite.
Sprite.setRotation (rotation)
Set a rotation angle for the sprite
Sprite.setSceneObject (sceneObject)
Set the parent scene object for the sprite.
Sprite.setSize (width, height, resetScaleFactor)
Set the world space size of the sprite
Sprite.setSortPoint (x, y)
Set a sort point for the sprite. This will be used in the calculations to determine whether the sprite should appear in front of other sprites in the same layer, according to the layer's sorting mode.
Sprite.setVisible (toggle)
Show or hide a sprite
Sprite.step ()
Perform a simulation step for the sprite. This involves updating the sprite's animation, if there is one that is currently playing.
Sprite.stopAnimation ()
Stop the animation that is currently playing
Sprite.usePixelPerfectMouseEvents (threshold)
Set the Sprite to use (or not use) pixel-perfect mouse events, i.e. discard mouse events on transparent pixels. By default, Sprites do not use pixel-perfect mouse events. Enabling this has implications for performance and memory usage.