Java Reference
In-Depth Information
function celebrate():Void{
(screen.status as Text).content = "Well Done!";
var timeline = Timeline{}
var count = (Main.random.nextInt(sizeof(fireworks))+1)*balloonMulti;
for (i in [0..count]){
var firework = fireworks[Main.random.nextInt(sizeof(fireworks)-1)];
insert KeyFrame{
time: i*.5s;
action: function(){
doFirework(firework);
};
} into timeline.keyFrames;
}
insert KeyFrame{
time: count*.5s + 1s;
action: function(){
nextClown();
}
} into timeline.keyFrames;
timeline.play();
}
// fireworks related functions found in Listing 11-6
function nextClown():Void{
if (clownsAvailable > 0){
readyLaunch();
} else {
endRound();
}
}
// section omitted for brevity
}
In Listing 11-3 we can see class GameModel , whose job it is to coordinate the state of the GameAssetsUI
call screen . In the init function we can see that a call to initScreen is made. The function initScreen
simplifies the gradients, removes some unwanted Nodes , and creates two buttons for managing game
state—just like the functions initStartScreen and initAboutScreen from Listing 11-1.
The function initScreen also does some other bookkeeping. There are a number of local variables
such as clownNode , cannonNode , bucketNode , and net that are assigned by a call to Main.offsetFromZero .
The function Main.offsetFromZero can be seen in Listing 11-1. This function is used to wrap a Node
within screen with a new Group . This is necessary because the Nodes defined within an fxz file do not
have their translateX and translateY values set. Looking at Nodes with an fxz file will help explain this.
Listing 11-4 shows the Node bonusBalloon from the fxz file.
Search WWH ::




Custom Search