API Documentation for: 2.3.1
Show:

BitmapMovieClip Class

Extends createjs.Container
Defined in: BitmapMovieClip:3
Namespace: cloudkid

A class similar to createjs.MovieClip, but made to play animations from a cloudkid.TextureAtlas. The CreateJS Sprite class requires a spritesheet with equal sized and spaced frames. By using cloudkid.TextureAtlas, you can use a much smaller spritesheet, sprites on screen with fewer extra transparent pixels, and use the same API as MovieClip.

See "Export BitmapMovieClip.jsfl" in the library for a script that will export a selected MovieClip in the library with all of the information (except data.scale) needed to reassemble the BitmapMovieClip.

Constructor

BitmapMovieClip

(
  • atlas=null
  • data=null
  • [data.fps]
  • [data.labels]
  • [data.origin={x:0,y:0}]
  • [data.frames]
  • [data.frames.name]
  • [data.frames.min]
  • [data.frames.max]
  • [data.frames.digits=4]
  • [data.scale=1]
)

Defined in BitmapMovieClip:3

Parameters:

  • atlas=null TextureAtlas

    The texture atlas to pull frames from.

  • data=null Object

    Initialization data

  • [data.fps] Int optional

    Framerate to play the movieclip at. Omitting this will use the current framerate.

  • [data.labels] Object optional

    A dictionary of the labels in the movieclip to assist in playing animations.

  • [data.origin={x:0,y:0}] Object optional

    The origin of the movieclip.

  • [data.frames] Array optional

    An array of frame sequences to pull from the texture atlas.

  • [data.frames.name] String optional

    The name to use for the frame sequence. This should include a "#" to be replaced with the image number.

  • [data.frames.min] Int optional

    The first frame number in the frame sequence.

  • [data.frames.max] Int optional

    The last frame number in the frame sequence.

  • [data.frames.digits=4] Int optional

    The maximum number of digits in the names of the frames, e.g. myAnim0001 has 4 digits.

  • [data.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.

    Format for 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 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 frame. 'digits' is optional, and defaults to 4.

Methods

_goto

(
  • positionOrLabel
)
protected

Defined in _goto:477

Parameters:

  • positionOrLabel String | Number

    The animation name or frame number to go to.

_reset

() private

Defined in _reset:527

_tick

(
  • props
)
protected

Defined in _tick:466

Parameters:

  • props Object

    Properties to copy to the DisplayObject DisplayObject/tick event object. function.

_updateTimeline

() protected

Defined in _updateTimeline:507

advance

(
  • [time]
)

Defined in advance:303

Advances the playhead. This occurs automatically each tick by default.

Parameters:

  • [time] Number optional

    The amount of time in ms to advance by. Only applicable if framerate is set.

copyFrom

(
  • other
)

Defined in copyFrom:435

Copies the labels, textures, origin, and framerate from another BitmapMovieClip. The labels and textures are copied by reference, instead of a deep copy.

Parameters:

destroy

()

Defined in destroy:452

Destroys the BitmapMovieClip, removing all children and nulling all reference variables.

draw

(
  • ctx
  • ignoreCache
)

Defined in draw:249

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.

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).

getCurrentLabel

() String

Defined in getCurrentLabel:336

Returns the name of the label on or immediately before the current frame. See TweenJS: Timeline.getCurrentLabel() for more information.

Returns:

String:

The name of the current label or null if there is no label.

getLabels

() ArrayObject

Defined in getLabels:327

Returns a sorted list of the labels defined on this BitmapMovieClip. Shortcut to TweenJS: Timeline.getLabels();

Returns:

ArrayObject:

A sorted array of objects with label and position (aka frame) properties.

gotoAndPlay

(
  • positionOrLabel
)

Defined in gotoAndPlay:283

Advances this movie clip to the specified position or label and sets paused to false.

Parameters:

  • positionOrLabel String | Number

    The animation name or frame number to go to.

gotoAndStop

(
  • positionOrLabel
)

Defined in gotoAndStop:293

Advances this movie clip to the specified position or label and sets paused to true.

Parameters:

  • positionOrLabel String | Number

    The animation or frame name to go to.

init

(
  • atlas
  • data
)

Defined in init:355

Returns the name of the label on or immediately before the current frame. See TweenJS: Timeline.getCurrentLabel() for more information.

Parameters:

  • atlas 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
        The name to use for the frame sequence. This should include a "#" to be replaced with the image number.
      • [min] Int optional
        The first frame number in the frame sequence.
      • [max] Int optional
        The last frame number in the frame sequence.
      • [digits=4] Int optional
        The maximum number of digits in the names of the frames, e.g. myAnim0001 has 4 digits.
    • [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.

      Format for data: { fps:30, labels: { animStart:0, animStart_loop:15 }, origin:{ x: 20, y:30 }, frames: [ { name:"myAnim#", min:1, max:20, digits:4 } ] }

      The 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 frame. 'digits' is optional, and defaults to 4.

isVisible

() Boolean

Defined in isVisible:237

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

play

()

Defined in play:267

Sets paused to false.

stop

()

Defined in stop:275

Sets paused to true.

Properties

_bitmap

createjs.Bitmap private

Defined in _bitmap:186

The Bitmap used to render the current frame of the animation.

_currentTexture

cloudkid.TextureAtlas.Texture private

Defined in _currentTexture:210

The current texture.

_duration

Number private

Defined in _duration:160

When the BitmapMovieClip is framerate independent, this is the total time in seconds for the animation.

Default: 0

_framerate

Number private

Defined in _framerate:148

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

_frames

Array private

Defined in _frames:202

An array of textures.

_labels

Array private

Defined in _labels:194

An array of frame labels.

_origin

createjs.Point private

Defined in _origin:218

The origin point of the BitmapMovieClip.

_prevPosition

Number private

Defined in _prevPosition:178

Default: 0

_scale

Number private

Defined in _scale:226

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

Number private

Defined in _t:169

When the BitmapMovieClip is framerate independent, this is the time elapsed from frame 0 in seconds.

Default: 0

advanceDuringTicks

Boolean

If true, the BitmapMovieClip will advance its timeline during ticks. If false then it must be externally advanced.

Default: true

currentFrame

Number

Defined in currentFrame:75

The current frame of the movieclip.

Default: 0

elapsedTime

Number public

Defined in elapsedTime:130

When the BitmapMovieClip is framerate independent, this is the time elapsed from frame 0 in seconds.

Default: 0

framerate

Number

Defined in framerate:100

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

Boolean

Defined in loop:67

Indicates whether this BitmapMovieClip should loop when it reaches the end of its timeline.

Default: true

paused

Boolean

Defined in paused:84

If true, the BitmapMovieClip's position will not advance when ticked.

Default: false