I am building a spritesheetbuilder class when I can pass in spritesheets that may have a different number of total frames and I would like to know is there a way to dynamically find out how many frames there are in a spritesheet and then loop through them all without having to setup the animations frame by frame? The loop parameter is a boolean value already working.
//SpriteSheetAnimator(bmp, w, h, loop)
this.monitor = new SpriteSheetAnimator(loader.getResult('img'), 204, 189, true);
//inside the SpriteSheetAnimator object
this._ss = new createjs.SpriteSheet({
animations:{
play:{
frames: [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22],
speed: 0.4
},
images:[this.bmp],
frames: {
width:this.width,
height:this.height,
regX:this.width*0.5,
regY:this.height*0.5
}
});
To play all of the frames in a Sprite
, just play it from 0
: mySprite.gotoAndPlay(0)
To get the number of frames, use mySpriteSheet.getNumFrames()
.