Java Reference
In-Depth Information
has fallen below the top of the net. If the clown is in the bucket or has fallen into the net, the current shot
is over.
If the clown is in the bucket, then the function celebrate is called, which creates a number of
firework effects. In Listing 11-3 we can see that the function celebrate creates a Timeline called
timeline , which kicks off a firework every .5 seconds by calling doFirework . The Timeline also calls
nextClown when the fireworks display is over. Looking at the function doFirework , we see it creates yet
another Timeline that animates a Circle called shell up into the scene. This Timeline also calls
doExplosion when shell reaches its apex. Listing 11-6 shows the functions related to displaying the
fireworks. The function doExplosion adds a new Explosion to the scene and then creates a Timeline that
will remove the Explosion after 4 seconds. Listing 11-7 shows the implementation of the class Explosion .
Listing 11-6. GameModel.fx (firework-related functions)
function doFirework(firework:Group):Void{
var shell = Circle{
radius: 4
fill: Color.DARKBLUE
}
insert shell into firework.content;
var timeline = Timeline{
keyFrames: [
KeyFrame{
time: .5s
values: shell.translateY => -250 tween Interpolator.SPLINE(.43, .79,
.84, 1.0)
action: function(){
doExplosion(firework, shell.translateX, shell.translateY);
delete shell from firework.content;
}
}
]
}
timeline.play();
}
function doExplosion(firework:Group, x:Number, y:Number):Void{
var explosion = Explosion{
translateX: x;
translateY: y;
}
insert explosion into firework.content;
var timeline = Timeline{
keyFrames: KeyFrame{
time: 4s
Search WWH ::




Custom Search