Java Reference
In-Depth Information
gravity: .002
effect: hue2;
scaleX: .4
scaleY: .4
} into content;
}
moveSparks.play();
}
public function stop():Void{
moveSparks.stop();
}
}
In Listing 11-7 we see that the class
Explosion
is very much like the class
Emitter
from Chapter 2.
The
init
function of
Explosion
adds two sets of
Particles
to its
content
, and these two sets create the
firework effect. The class
Particle
is a direct copy of the class from Chapter 2. As the
Timeline
moveSparks
runs, it calls the
doStep
function on each
Particle
, causing each
Particle
to animate in the
scene. In this case, each
Particle
travels away from the location of the
Explosion
in a random direction,
fading as it goes.
Once all of the
Explosions
are done animating, the code path is then identical to the code path when
the clown hit the net instead of the bucket. The function
nextClown
is called and checks to see if the user
has fired all of his clowns or not. If clowns remain, the function
readyLaunch
is called and the process
repeats. If there are no more clowns the user is presented with a dialog, allowing him to either play again
or go back to the start screen.
Summary
This chapter started with a design for a game that incorporated many of the effects described in this
topic. That initial design was used to create game assets in Adobe Illustrator. The details and workflow
decisions of working with the JavaFX Production Suite provided a real-world context for using this tool.
The implementation of Clown Cannon showed how to glue all of the effects together to create a
complete game. This glue included understanding the life cycle of the entire game as well as each round.