Understanding API and methods of TweenJS

In order to create animations in TweenJS, you don't have to work with a lot of methods. There are a few functions that help you to create animations. Following are all the methods with a brief description:

  • get: It returns a new tween instance.
  • to: It queues a tween from the current values to the target properties.
  • set: It queues an action to set the specified properties on the specified target.
  • wait: It queues a wait (essentially an empty tween).
  • call: It queues an action to call the specified function.
  • play: It queues an action to play (un-pause) the specified tween.
  • pause: It queues an action to pause the specified tween.

The following is an example of using the Tweening API:

var tween = createjs.Tween.get(myTarget).to({x:300},400).set({label:"hello!"}).wait(500).to({alpha:0,visible:false},1000).call(onComplete);

The previous example will create a tween, which:

  • Tweens the target to an x value of 300 with duration 400ms and sets its label to hello!.
  • Waits 500ms.
  • Tweens the target's alpha property to 0 with duration 1s and sets the visible property to false.
  • Finally, calls the onComplete function.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.3.175