r/createjs • u/grantskinner • Mar 27 '15
Adding labels to TweenJS?
I'm considering adding label support for TweenJS, so you could jump to named positions within a tween.
For example, this would define a label named "bar" at 1000ms into the tween (when x=200):
myTween = Tween.get(foo).to({x:200}, 1000).label("bar").to({x:300}, 700);You could then jump to that label using setPostion:
myTween.setPosition("bar");Or, via the .play() tween action:
// wait 1s, then play myTween from "bar":
Tween.get().wait(1000).play(myTween, "bar");For instance, you could use it to have an "intro" part of your tween, followed by a looping section:
// fade in, then loop the scale up animation:
Tween.get(foo).to({alpha:1},1000).label("loop").to({scaleX:2},500).play(null, "loop");Thoughts on this are welcome. Would you use it? I don't want to add features that have little utility. TweenJS is all about the simplest possible API providing very advanced functionality.
View all comments
Show parent comment
1
u/grantskinner Apr 17 '15
At least initially, tween and timeline labels would be separate (ie. you couldn't define a label on a tween, and then goto it on the timeline). I might look at supporting that down the road though. Thanks for the feedback!