Class Index | File Index

Classes


Class Sprite


Extends DisplayObject.
Sprites are nestable display lists that allow you to work with compound display elements. For example you could group arm, leg, torso and head Bitmaps together into a Person Sprite, and transform them as a group, while still being able to move the individual parts relative to each other. Children of sprites have their transform and alpha properties concatenated with their parent Sprite. For example, a Shape with x=100 and alpha=0.5, placed in a Sprite with x=50 and alpha=0.7 will be rendered to the canvas at x=150 and alpha=0.35. Sprites have some overhead, so you generally shouldn't create a Sprite to hold a single child.
Defined in: Sprite.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Sprite()
Constructs a new Sprite instance.
Field Summary
Field Attributes Field Name and Description
<private>  
<private>  
<private>  
 
The array of children in the display list.
 
Indicates whether the children of this Sprite should be tested in getObjectsUnderPoint() and getObjectUnderPoint() calls.
Fields borrowed from class DisplayObject:
_activeContext, _cacheDraw, _cacheOffsetX, _cacheOffsetY, _restoreContext, _revertShadow, _revertX, _revertY, alpha, cacheCanvas, id, mouseEnabled, name, parent, regX, regY, rotation, scaleX, scaleY, shadow, visible, x, y
Method Summary
Method Attributes Method Name and Description
<private>  
_getObjectsUnderPoint(x, y, ctx, arr)
<private>  
_testHit(x, y, ctx)
 
addChild(child)
Adds a child to the top of the display list.
 
addChildAt(child, index)
Adds a child to the display list at the specified index, bumping children at equal or greater indexes up one, and setting its parent to this Sprite.
<private>  
 
getChildAt(index)
Returns the child at the specified index.
 
Returns the index of the specified child in the display list, or -1 if it is not in the display list.
 
Returns the number of children in the display list.
<private>  
init()
 
Removes all children from the display list.
 
removeChild(child)
Removes the specified child from the display list.
 
Removes the child at the specified index from the display list, and sets its parent to null.
 
sortChildren(sortFunction)
Performs an array sort operation on the child list.
Methods borrowed from class DisplayObject:
applyShadow, cache, clone, draw, getStage, revertContext, toString, uncache, updateContext
Class Detail
Sprite()
Constructs a new Sprite instance.
Field Detail
<private> _cloneProps

<private> _draw

<private> _init

children
The array of children in the display list. You should usually use the child management methods, rather than accessing this directly, but it is included for advanced users. *

mouseChildren
Indicates whether the children of this Sprite should be tested in getObjectsUnderPoint() and getObjectUnderPoint() calls. *
Method Detail
<private> _getObjectsUnderPoint(x, y, ctx, arr)
Parameters:
x
y
ctx
arr

<private> _testHit(x, y, ctx)
Parameters:
x
y
ctx

addChild(child)
Adds a child to the top of the display list. Returns the child that was added.
Parameters:
child
The display object to add.

addChildAt(child, index)
Adds a child to the display list at the specified index, bumping children at equal or greater indexes up one, and setting its parent to this Sprite. The index must be between 0 and numChildren. For example, to add myShape under otherShape in the display list, you could use: sprite.addChildAt(myShape, sprite.getChildIndex(otherShape)). This would also bump otherShape's index up by one. Returns the child that was added.
Parameters:
child
The display object to add.
index
The index to add the child at.

<private> cloneProps(o)
Parameters:
o

getChildAt(index)
Returns the child at the specified index.
Parameters:
index
The index of the child to return.

getChildIndex(The)
Returns the index of the specified child in the display list, or -1 if it is not in the display list.
Parameters:
The
child to return the index of.

getNumChildren()
Returns the number of children in the display list.

<private> init()

removeAllChildren()
Removes all children from the display list.

removeChild(child)
Removes the specified child from the display list. Note that it is faster to use removeChildAt() if the index is already known. Returns true if the child was removed, or false if it was not in the display list.
Parameters:
child
The child to remove.

removeChildAt(The)
Removes the child at the specified index from the display list, and sets its parent to null. Returns true if the child was removed, or false if the index was out of range.
Parameters:
The
index of the child to remove.

sortChildren(sortFunction)
Performs an array sort operation on the child list.
Parameters:
sortFunction

Documentation generated by JsDoc Toolkit 2.3.2 on Tue Dec 07 2010 15:40:00 GMT-0700 (MST)