Game Development Reference
In-Depth Information
Figure 17-33 . Add the logic inside the if-else structure that flips the sprite and positions it on either side of the screen
Powering the Enemy .update() Method: Using the
GamePlayLoop .handle() Method
Before we can start to test the code inside the Enemy.java class .update() method, we
must “wire it up” to the .handle() method in the GamePlayLoop.java class. As you
know, this method is our doorway into the JavaFX pulse timing event processing en-
gine that drives our game at a lightning fast 60 FPS. Now our GamePlayLoop .handle()
method will be updating both an iBagel InvinciBagel character as well as the iBeagle
Enemy auto-attack programming logic. It is easy to see why InvinciBagel and Invin-
ciBeagle are enemies; it's an identity crisis of sorts, kind of like one of those mis-
spelled domain name disputes! Your Java code, seen error-free in Figure 17-34 , will
look like the following:
@Override
public void handle (long now)
{
invinciBagel. iBagel .update();
 
 
Search WWH ::




Custom Search