Game Development Reference
In-Depth Information
Figure 7-9 . Click the InvinciBagel.java editing tab, and declare a GamePlayLoop object named gamePlayLoop at
the top
As you can see, the code is error free, because NetBeans has found your
GamePlayLoop class, which contains the overridden .handle() method and whose par-
ent AnimationTimer class has a constructor method that can create an AnimationTimer
(type of) object, using the GamePlayLoop class, extending AnimationTimer.
Now, you have to instantiate, or create, an instance in memory of the
GamePlayLoop object, using the Java new keyword. This is done once, when the game
is first started, which means that the instance needs to go in the .start() method.
You can do this after all the other Scene Graph Node objects and ActionEvent
EventHandler objects have been created, using the following line of Java code (see also
Figure 7-10 ) :
gamePlayLoop = new GamePlayLoop();
 
 
Search WWH ::




Custom Search