Game Development Reference
In-Depth Information
There are several animation effects at your disposal, many of which are quite silly but may come in handy in
dramatic situations. Play around with different options to get the effect you are looking for. For more information and
examples of the included tween animations, check out the Spark Table that is available from the TweenJS web page
(see Figure 1-5 ).
Figure 1-5. Spark Table with animated samples of Ease equations
There are two more important things you need to look into with TweenJS, the wait and call methods.
The wait method allows you to specify a desired time to delay before executing your animation. The following
example waits 2 seconds before animating your butterfly:
createjs.Tween.get(butterfly).wait(2000).to({y:butterfly.y + 20},1000);
The call method allows you to call on a function when your animation is complete. This is referred to as a
callback, which is simply a function that will be called asynchronously from other executing commands. This is an
important feature in game development but can quickly get confusing because of the nature of JavaScript scope.
Callbacks and Scope
Before fully explaining JavaScript callbacks, let's take one more look at a Tween command that utilizes the call
method.
create.js.Tween.get(butterfly).to({alpha:0,1000 ).call(butterflyGone);
 
Search WWH ::




Custom Search