Class Stage
Extends
Sprite.
A stage is the root level Sprite for a display list. Each time its tick method is called, it will render its display list to its target canvas.
Defined in: Stage.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Stage(canvas)
Constructs a Stage object with the specified target canvas.
|
Field Attributes | Field Name and Description |
---|---|
<private> | |
<private> | |
<private> | |
Indicates whether the stage should automatically clear the canvas before each render.
|
|
The canvas the stage will render to.
|
- Fields borrowed from class Sprite:
- _cloneProps, _draw, _init, children, mouseChildren
- 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 Attributes | Method Name and Description |
---|---|
<private> |
_getObjectsUnderPoint(x, y, arr)
|
clear()
Clears the target canvas.
|
|
getObjectsUnderPoint(x, x)
Returns an array of all display objects under the specified canvas coordinates that are in this stage's display list.
|
|
getObjectUnderPoint(x, x)
Similar to getObjectsUnderPoint(), but returns only the top-most display object.
|
|
<private> |
init(canvas)
|
tick()
Each time tick is called, the stage will render its entire display list to the canvas.
|
- Methods borrowed from class Sprite:
- _testHit, addChild, addChildAt, cloneProps, getChildAt, getChildIndex, getNumChildren, removeAllChildren, removeChild, removeChildAt, sortChildren
- Methods borrowed from class DisplayObject:
- applyShadow, cache, clone, draw, getStage, revertContext, toString, uncache, updateContext
Class Detail
Stage(canvas)
Constructs a Stage object with the specified target canvas.
- Parameters:
- canvas
- The canvas the stage will render to.
Field Detail
<private>
__getObjectsUnderPoint
<private>
__init
<private>
_tmpCanvas
autoClear
Indicates whether the stage should automatically clear the canvas before each render. You can set this to false to manually control clearing (for generative art, or when pointing multiple stages at the same canvas for example). *
canvas
The canvas the stage will render to. Multiple stages can share a single canvas, but you must disable autoClear for all but the first stage that will be ticked (or they will clear each other's render). *
Method Detail
<private>
_getObjectsUnderPoint(x, y, arr)
- Parameters:
- x
- y
- arr
clear()
Clears the target canvas. Useful if autoClear is set to false.
getObjectsUnderPoint(x, x)
Returns an array of all display objects under the specified canvas coordinates that are in this stage's display list. This routine ignores any display objects with mouseEnabled set to false (the default) or that are inside sprites with mouseChildren set to false (the default). The array will be sorted in order of visual depth, with the top-most display object at index 0. This uses shape based hit detection, and can be an expensive operation to run, so it is best to use it carefully. For example, if testing for objects under the mouse, test on tick (instead of on mousemove), and only if the mouse's position has changed.
- Parameters:
- x
- The x coordinate to test.
- x
- The y coordinate to test.
getObjectUnderPoint(x, x)
Similar to getObjectsUnderPoint(), but returns only the top-most display object. This runs significantly faster than getObjectsUnderPoint(), but is still an expensive operation. See getObjectsUnderPoint() for more information.
- Parameters:
- x
- The x coordinate to test.
- x
- The y coordinate to test.
<private>
init(canvas)
- Parameters:
- canvas
tick()
Each time tick is called, the stage will render its entire display list to the canvas.