Game Development Reference
In-Depth Information
The first thing that we will need to do is to tell our GamePlay Engine in the
GamePlayLoop AnimationTimer subclass that we want to have it look at (update) the
iBagel Bagel object on every pulse. There are two major lines of code that we will need
to install in the GamePlayLoop.java class for this to happen. The first is a reference to
the static Bagel object named iBagel that we declared in the code that is shown in Fig-
ure 11-3 using the import static invincibagel.InvinciBagel.iBagel
Java statement. The second line of code that we need to install will live inside of the
.handle() method, and will serve to “wire” the .handle() method (the pulse engine) to
the iBagel object using its .update() method. The new GamePlayLoop class import
statements and .handle() method should look like the following Java code, shown error-
free in Figure 11-11 :
import javafx.animation.AnimationTimer;
import static invincibagel.InvinciBagel.iBagel;
public class GamePlayLoop extends AnimationTimer {
@Override
public void handle (long now ) {
iBagel.update();
}
}
 
 
Search WWH ::




Custom Search