Game Development Reference
In-Depth Information
In case you are wondering why you are not seeing any “blips” in the Thread objects
shown in Figure 7-12 , like you did when you clicked the Button objects in the previous
chapter, you are correct in your assumption that you should see the JavaFX pulse en-
gine timing events somewhere in this diagram Yet, all the thread bars are solid colored,
so no action or pulse events are firing. I am going to have you use the NetBeans profil-
ing utility as often as necessary to get you used to it, as many developers avoid this tool
because they have not become comfortable with it.
This reason you do not see any events is that simply creating the GamePlayLoop
object is not enough for the .handle() method inside it to grab hold of pulse events. Be-
cause it is a Timer object of sorts (an AnimationTimer, to be exact), like any timer, it
needs to be started and stopped . Let's create these methods for the GamePlayLoop
next.
Controlling
Your
GamePlayLoop:
.start() and .stop()
Because the AnimationTimer superclass has the .start() and .stop() methods, which
control when the class (object) will (using a .start() method call) and will not (using a
.stop() method call) handle pulse events, you will simply pass these functions “up” to
the AnimationTimer superclass, using the Java super keyword inside your method
code. You will override the .start() method by using the Java @Override keyword and
then pass the method call functionality up to the AnimationTimer superclass by using
the following method programming structure:
@Override
public void start() {
super .start();
}
The .stop() method structure will be overridden, and the method functionality,
passed up to the superclass, in exactly the same fashion, using the following Java meth-
od programming structure:
@Override
public void stop() {
Search WWH ::




Custom Search