Game Development Reference
In-Depth Information
Figure
7-1 .
Javafx.animation
package
subclass
hierarchy;
top
level
classes
all
coded
from
scratch
with
java.lang.Object
There are four basic approaches to implementing (accessing) the JavaFX pulse
event timing system to create a game timing loop. These different approaches apply to
the different types of game play, which I discussed previously (see Chapter 5 ) . These
game play types range from static games (board games, puzzle games) that need to use
the pulse event engine to implement special effects ( Transition subclasses) or custom
animations ( Timeline class, in conjunction with the KeyFrame class and possibly the
KeyValue class) to highly dynamic games that need no-frills core access to the pulse
event system at the full 60 times per second game play refresh rate ( AnimationTimer
class).
The highest level (visually, the lowest level, shown at the bottom left of the figure)
is the use of prebuilt Transition subclasses in the javafx.animation package, such as
the PathTransition class (or object), for the path of the game sprites or projectiles, or
TranslateTransition, which translates (moves) things on the screen. All these Transition
subclasses are coded for you; all you have to do is use them, which is why I am label-
ing this the highest functional level, in this particular discussion. With this high level of
prebuilt functionality comes a memory and processing price; this is because, as you
know from what you learned about Java inheritance (see Chapter 3 ) , the PathTransition
class contains all its methods, variables, and constants as well as those from all the
classes above it in the class hierarchy.
This means that the entire PathTransition class, the Transition superclass, the An-
imation superclass, and the java.lang.Object masterclass are all contained within the
memory footprint for this class and potentially the processing overhead, too, depending
on how the object is implemented using the class. This is something to consider, as the
lower down you go in the JavaFX animation package, the more expensive it is and the
more control you give the code that has been written for you rather than custom code
you are writing yourself.
The next-highest-level approach to coding custom game loops is to subclass the
javafx.animation.Transition class to create your own customized Transition subclass.
 
 
Search WWH ::




Custom Search