Game Development Reference
In-Depth Information
GamePlayLoop.java class. This class extends the JavaFX AnimationTimer superclass
to provide access to the JavaFX pulse timing engine for our game. Inside of the .cre-
ateStartGameLoop() method we are going to use the Java new keyword to create a
pulse engine for our game named gamePlayLoop using the GamePlayLoop() construct-
or method. After that, we are going to call the .start() method off of this gamePlayLoop
object to start the pulse event timing engine. This call is done by using the following
four lines of Java programming logic, which are also shown error-free in Figure 11-9 :
private void createStartGameLoop() {
gamePlayLoop = new GamePlayLoop();
gamePlayLoop .start() ;
}
Figure 11-9 . Create a private void createStartGameLoop() method, and create and .start() the gamePlayLoop object
As you can see at the bottom of Figure 11-9 , I have collapsed the other method
structures, and I have them in the same order in the code that they are called within the
.start() method, for organization purposes. I start a game play loop last because I want
to make sure I have done absolutely everything else that I need to do to set up the game
environment first, before I start the JavaFX pulse engine firing and launch the game.
As you can see, I'm using the Java method names, and my game code design, to keep
me reminded about what I need to do every time that I add some new game actor,
 
 
Search WWH ::




Custom Search