Game Development Reference
In-Depth Information
want a short pause before an animation starts playing or you might
have a series of animations that you want to play when a player
does something.
To Tween or Not to Tween? Is That
a Question?
When creating animation in a game, there are generally two
methods to use. The first is to create scripted animation, which is
to move objects based on the game
s mechanic. An example of this
would be a top
down scrolling shooting game in which the speeds,
positions, and orientations of the background, player, and enemies
are all determined by engine calculations and updated frame-by-
frame. Another example would be any kind of physics simulation,
which we
ll discuss in-depth in Chapter 11.
The second method is to create what is commonly known as a
tween . A tween is a set of instructions that change the properties of
an object over time. For instance, if I move a circle from (0, 0) to
(10, 10) in two seconds, I have tweened that object
s x and y prop-
erties. Since version 7, Flash has included some basic classes for
creating tweens with code. These classes have changed very little
all the way through version 10, where we are today. However, a
number of Flash users in the community have taken it upon them-
selves to write elaborate tweening libraries that support things such
as moving multiple objects in sync with each other, dispatching
events when animations begin, change, and end, and sequencing
entire virtual timelines of animation. Tweens are less useful when
creating simulation-driven games, but they are extraordinarily help-
ful, when you simply need to move or manipulate components of a
game or create visual effects in a style you might have traditionally
used the timeline for in earlier versions of Flash. Although I
used a number of tweening libraries and each of those has its own
merits, my favorite as of this writing is TweenMax by Jack Doyle of . Jack goes to great lengths to incorporate feedback
from the community and continues to update and improve the
library on his own time. It is the tween engine we
ll use in some
upcoming examples, and I highly recommend downloading the lat-
est version from his site and donating to the project if you end up
using it in your own work.
A Simple Scripted Shooter
In the following example, we will look at a simple animated game
mechanic involving a top
down, scrolling shooter. This game will
use a form of scripted animation to convey a sense of motion to
Search Nedrilad ::

Custom Search