A class similar to createjs.MovieClip, but made to play animations from a springroll.easeljs.TextureAtlas. The EaselJS Sprite class requires a spritesheet with equal sized and spaced frames. By using TextureAtlas, you can use a much smaller spritesheet, sprites on screen with fewer extra transparent pixels, and use the same API as MovieClip.
Format for BitmapMovieClip data:
{
fps:30,
labels:
{
animStart:0,
animStart_loop:15
},
origin:{ x: 20, y:30 },
frames:
[
{
name:"myAnim#",
min:1,
max:20,
digits:4
}
],
scale:1
}
The example object describes a 30 fps animation that is 20 frames long, and was originally myAnim0001.png->myAnim0020.png, with frame labels on the first and 16th frames. 'digits' is optional, and defaults to 4.
springroll.easeljs.BitmapMovieClip
[atlas]
[data]
[atlas]
springroll.easeljs.TextureAtlas
optional
The texture atlas to pull frames from.
[data]
Object
optional
Initialization data
[fps]
Int
optional
Framerate to play the movieclip at. Omitting this will use the current framerate.
[labels]
Object
optional
A dictionary of the labels in the movieclip to assist in playing animations.
[origin={x:0,y:0}]
Object
optional
The origin of the movieclip.
[frames]
Array
optional
An array of frame sequences to pull from the texture atlas.
[name]
String
optional
[min]
Int
optional
[max]
Int
optional
[digits=4]
Int
optional
[scale=1]
Number
optional
The scale at which the art was exported, e.g. a scale of 1.4 means the art was increased in size to 140% before exporting and should be scaled back down before drawing to the screen.
_tick
props
props
Object
Properties to copy to the DisplayObject DisplayObject/tick event object. function.
advance
[time]
Advances the playhead. This occurs automatically each tick by default.
[time]
Number
optional
The amount of time in ms to advance by. If 0 or null, time is not advanced but the timeline is still updated.
cacheByBounds
[buffer=0]
[scale=1]
[buffer=0]
Int
optional
[scale=1]
Number
optional
cacheByRect
rect
[buffer=0]
[scale=1]
rect
createjs.Rectangle
[buffer=0]
Int
optional
[scale=1]
Number
optional
clone
sprite
[x=0]
[y=0]
Clone a sprite. Creates a shallow copy of loaded element
sprite
springroll.easeljs.BitmapMovieClip
The sprite to clone
[x=0]
Number
optional
The initial x position
[y=0]
Number
optional
The initial y position
copyFrom
other
Copies the labels, textures, origin, and framerate from another BitmapMovieClip. The labels and textures are copied by reference, instead of a deep copy.
other
BitmapMovieClip
The movieclip to copy data from.
draw
ctx
ignoreCache
Draws the display object into the specified context ignoring its 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.
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).
getCurrentLabel
Returns the name of the label on or immediately before the current frame.
The name of the current label or null if there is no label.
getEvents
Returns a sorted list of the labels which can be played with Animator.
A sorted array of objects with label, length and position (aka frame) properties.
getLabels
Returns a sorted list of the labels defined on this BitmapMovieClip.
A sorted array of objects with label and position (aka frame) properties.
gotoAndPlay
positionOrLabel
Advances this movie clip to the specified position or label and sets paused to false.
gotoAndStop
positionOrLabel
Advances this movie clip to the specified position or label and sets paused to true.
init
atlas
data
Initializes or re-initializes the BitmapMovieClip.
atlas
springroll.easeljs.TextureAtlas
The texture atlas to pull frames from.
data
Object
Initialization data
[fps]
Int
optional
Framerate to play the movieclip at. Omitting this will use the current framerate.
[labels]
Object
optional
A dictionary of the labels in the movieclip to assist in playing animations.
[origin={x:0,y:0}]
Object
optional
The origin of the movieclip.
[frames]
Array
optional
An array of frame sequences to pull from the texture atlas.
[name]
String
optional
[min]
Int
optional
[max]
Int
optional
[digits=4]
Int
optional
[scale=1]
Number
optional
The scale at which the art was exported, e.g. a scale of 1.4 means the art was increased in size to 140% before exporting and should be scaled back down before drawing to the screen.
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.
Boolean indicating whether the display object would be visible if drawn to a canvas
_duration
When the BitmapMovieClip is framerate independent, this is the total time in seconds for the animation.
Default: 0
_framerate
By default BitmapMovieClip instances advance one frame per tick. Specifying a framerate for the BitmapMovieClip will cause it to advance based on elapsed time between ticks as appropriate to maintain the target framerate.
Default: 0
_scale
A scale to apply to the images in the BitmapMovieClip to restore normal size (if spritesheet was exported at a smaller or larger size).
_t
When the BitmapMovieClip is framerate independent, this is the time elapsed from frame 0 in seconds.
Default: 0
elapsedTime
When the BitmapMovieClip is framerate independent, this is the time elapsed from frame 0 in seconds.
Default: 0
framerate
By default BitmapMovieClip instances advance one frame per tick. Specifying a framerate for the BitmapMovieClip will cause it to advance based on elapsed time between ticks as appropriate to maintain the target framerate.
For example, if a BitmapMovieClip with a framerate of 10 is placed on a Stage being updated at 40fps, then the BitmapMovieClip will advance roughly one frame every 4 ticks. This will not be exact, because the time between each tick will vary slightly between frames.
This feature is dependent on the tick event object (or an object with an appropriate "delta" property) being passed into Stage/update.
Default: 0
loop
Indicates whether this BitmapMovieClip should loop when it reaches the end of its timeline.
Default: true