Class BitmapAnimation
- extends DisplayObject
Displays frames or sequences of frames (ie. animations) from a sprite sheet image. A sprite sheet is a series of images
(usually animation frames) combined into a single image. For example, an animation
consisting of 8 100x100 images could be combined into a 400x200 sprite sheet (4 frames across by 2 high).
You can display individual frames, play frames as an animation, and even sequence animations
together. See the SpriteSheet class for more information on setting up frames and animations.
Constructor
BitmapAnimation
(
spriteSheet
)
- Parameters:
-
spriteSheet
<SpriteSheet>
The SpriteSheet instance to play back. This includes the source image(s), frame
dimensions, and frame data. See SpriteSheet for more information.
Properties
Returns the currently playing animation. READ-ONLY.
Specifies the current frame index within the current playing animation. When playing normally, this will
increase successively from 0 to n-1, where n is the number of frames in the current animation.
Default Value: 0
The frame that will be drawn when draw is called. Note that with some SpriteSheet data, this
will advance non-sequentially. READ-ONLY.
Default Value: -1
When used in conjunction with animations having an frequency greater than 1, this lets you offset which tick the playhead will
advance on. For example, you could create two BitmapAnimations, both playing an animation with a frequency of 2, but one
having offset set to 1. Both instances would advance every second tick, but they would advance on alternating
ticks (effectively, one instance would advance on odd ticks, the other on even ticks).
Default Value: 0
Specifies a function to call whenever any animation reaches its end. It will be called with two
params: the first will be a reference to this instance, the second will be the name of the animation
that just ended.
Prevents the animation from advancing each tick automatically. For example, you could create a sprite
sheet of icons, set paused to true, and display the appropriate icon by setting currentFrame.
Default Value: false
Whether or not the Bitmap should be draw to the canvas at whole pixel coordinates.
Default Value: true
The SpriteSheet instance to play back. This includes the source image, frame dimensions, and frame
data. See SpriteSheet for more information.
Properties inherited from DisplayObject:
_cacheDataURL,
_cacheDataURLID,
_cacheOffsetX,
_cacheOffsetY,
_matrix,
alpha,
cacheCanvas,
cacheID,
compositeOperation,
filters,
id,
mouseEnabled,
name,
parent,
regX,
regY,
rotation,
scaleX,
scaleY,
shadow,
skewX,
skewY,
snapToPixel,
visible,
x,
y
Methods
protected
void
_goto
(
frameOrAnimation
)
Moves the playhead to the specified frame number or animation.
- Parameters:
-
frameOrAnimation
<String|Number>
The frame number or animation that the playhead should move to.
- Returns:
void
protected
void
_normalizeCurrentFrame
(
)
Normalizes the current frame, advancing animations and dispatching callbacks as appropriate.
protected
void
_tick
(
)
Advances the currentFrame if paused is not true. This is called automatically when the Stage ticks.
void
advance
(
)
Advances the playhead. This occurs automatically each tick by default.
void
cache
(
)
Because the content of a Bitmap is already in a simple format, cache is unnecessary for Bitmap instances.
You should not cache Bitmap instances as it can degrade performance.
Point
clone
(
)
Returns a clone of the Point instance.
- Returns:
Point
- a clone of the Point instance.
protected
void
cloneProps
(
o
)
- Parameters:
-
o
<Text>
- Returns:
void
void
draw
(
ctx
,
ignoreCache
)
Draws the display object into the specified context ignoring it's visible, alpha, shadow, and transform.
Returns true if the draw was handled (useful for overriding functionality).
NOTE: This method is mainly for internal use, though it may be useful for advanced uses.
- Parameters:
-
ctx
<CanvasRenderingContext2D>
The canvas 2D context object to draw into.
-
ignoreCache
<Boolean>
Indicates whether the draw operation should ignore any current cache.
For example, used for drawing the cache (to prevent it from simply drawing an existing cache back
into itself).
- Returns:
void
void
gotoAndPlay
(
frameOrAnimation
)
Sets paused to false and plays the specified animation name, named frame, or frame number.
- Parameters:
-
frameOrAnimation
<String|Number>
The frame number or animation name that the playhead should move to
and begin playing.
- Returns:
void
void
gotoAndStop
(
frameOrAnimation
)
Sets paused to true and seeks to the specified animation name, named frame, or frame number.
- Parameters:
-
frameOrAnimation
<String|Number>
The frame number or animation name that the playhead should move to
and stop.
- Returns:
void
protected
void
initialize
(
)
Initialization method.
Boolean
isVisible
(
)
Returns true or false indicating whether the display object would be visible if drawn to a canvas.
This does not account for whether it would be visible within the boundaries of the stage.
NOTE: This method is mainly for internal use, though it may be useful for advanced uses.
- Returns:
Boolean
- Boolean indicating whether the display object would be visible if drawn to a canvas
String
toString
(
)
Returns a string representation of this object.
- Returns:
String
- a string representation of the instance.
void
uncache
(
)
Because the content of a Bitmap is already in a simple format, cache is unnecessary for Bitmap instances.
You should not cache Bitmap instances as it can degrade performance.
void
updateCache
(
)
Because the content of a Bitmap is already in a simple format, cache is unnecessary for Bitmap instances.
You should not cache Bitmap instances as it can degrade performance.
_applyFilters,
_testHit,
_tick,
applyShadow,
cache,
clone,
cloneProps,
draw,
getCacheDataURL.,
getConcatenatedMatrix,
getStage,
globalToLocal,
hitTest,
initialize,
isVisible,
localToGlobal,
localToLocal,
setTransform,
toString,
uncache,
updateCache