CreateJS / TweenJS

A simple but powerful tweening / animation library for Javascript. Part of the CreateJS suite of libraries.
http://createjs.com/
MIT License
3.56k stars 966 forks source link

n00b frustrated with TweenJS #23

Closed gilbox closed 11 years ago

gilbox commented 11 years ago

My frustrations (v0.4.0):

Am I just being dense or do others share my frustrations?

lannymcnie commented 11 years ago

Hi @gilbi

Thanks for your comments - hopefully I can answer some of them:

  1. setProps works in examples that I have tested. Can you provide a sample of it not working? Here is a simple demo of it working. http://jsfiddle.net/lannymcnie/s6Rxe/1/
  2. The play function and setPaused are totally different APIs. setPaused is an immediate "stop the tween" function, whereas the play function queues up a "play" action in the current tween queue, which will start a different tween that is currently paused.
// Create a tween, and pause it
var tween1 = createjs.Tween.get(target).to({y:100}, 2000);
tween1.setPaused(true);
// Create another tween. When it is done its first "to" action, it will call play on the first tween.
createjs.Tween.get(target)
    .to({x:100}, 2000)
    .play(tween1);
  1. You are correct, we should change the docs. Mainly you will not get any performance increase from caching a Bitmap, whereas you do from other DisplayObject types.
  2. Thanks for the heads up, I have corrected the documentation, marking this as required. It was just an oversight.

Cheers.

gilbox commented 11 years ago

@lannymcnie,

Thank you for your illuminating explanation re: setPaused.

Here is an example where set(...) does not do what I would expect:

http://jsfiddle.net/s6Rxe/20/

(In the example above, I want the text to move from x=200 to x=0 in 2000ms.)

lannymcnie commented 11 years ago

Definitely a bug or unexpected behaviour.

Looks like properties updated using the set() API get overridden by tween properties, which are stored in an internal look up to manage the tween.

A workaround would be to use a 0-duration tween instead of a set - but we will look into fixing this issue if possible.

createjs.Tween.get(target).to({x:100}, 0).to(etc...)

Thanks for the report!

lannymcnie commented 11 years ago

I distilled the example down to this to show the issue http://jsfiddle.net/lannymcnie/s6Rxe/22/

lannymcnie commented 11 years ago

I discussed this issue internally, and its behaving as expected. TweenJS uses managed properties to make tweens deterministic. The "set" method will only set properties once, but managed properties will always override them. To do an instant set of a managed property, use a "to" call (as in the demo above).

Thanks for your comments.