Game Development Reference
In-Depth Information
The Flag project
This example demonstrates playing back both a main and sub-animation. A flag is
rendered waving in a virtual breeze. Every few seconds the flagpole will wobble
around but the flag on the end of the pole will continue to flap around. A screen
grab can be seen in the following figure:
The animation of the flag waving is achieved as a looping sub-animation, while
the flagpole wobble is the main animation, which is started every five seconds as
a one-shot animation.
One of the problems with this approach is that the sub-animation will only play
if there is a main animation currently in progress. Rather than create a one frame
animation of the flagpole standing still, a cunning trick has been employed.
The flagpole wobble animation is actually playing continuously, but at zero speed.
Since the first frame of the wobble animation is of the pole in an upright position,
we have achieved our aim of a static animation frame.
Every five seconds the wobble animation is then restarted as a one-shot animation.
When the wobble animation has completed, we return to playing it at zero speed to
hold the flagpole steady again.
 
Search WWH ::




Custom Search