CreateJS : Listen for particular frame in Sprite animation or obtain frame label index? -


is there api listen particular frame during animation of sprite in createjs? there kind of way trigger events @ particular frames in flash movieclip, not sure how in createjs.

i achieve listening change event of sprite while animates, check currentframe on each event, check if frame index 1 want react, but, seems rather laboured, , means have hard code index instead of frame label.

interestingly, _animations property of sprite seems intended private, although can use property ascertain length of animation, again, still have hard code index value. (out of curiosity, why not have mysprite.length() api? flash's movieclip has number of frames prop...).

is there way make frame labels in createjs? in docs here, can see use of:

instance.gotoandstop("framename"); 

...but don't see documentation on how set frame labels in spritesheet particular animation sequence, or how retrieve index of frame associated frame label.

thanks help!

the gotoandstop , gotoandplay methods both allow frame number or animation name (not frame name). can label animations when create spritesheet, can not otherwise make named keyframes inside of animations.

to determine keyframe, check currentanimationframe (doc) on main tick function, or listen change event (doc) sprite.

sprite.on("tick", function() {     if (sprite.currentanimationframe == 10) {          //     } }); 

note depending on app framerate, might have store previous frame, , check if playhead has passed frame, easeljs may skip frames depending on speed of playback.

--

the length property idea, have method pass in animation name. have logged issue on easeljs github


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -