Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1

Chapter 7 ■ IntroduCtIon to JavaFX 9: overvIew oF the JavaFX new MedIa engIne


fxml module will allow you to use Java FXML, the XML language that allows user interface and graphics
design to be offloaded to XML instead of Java coding. This allows non-Java-savvy designers to work on a
game project. This approach is also used by the Android OS and Android Studio IDE, which uses XML for
many top-level design tasks so the designers don’t also have to be programmers.


Summary


In this seventh chapter, you got an overview of some of the most important packages, concepts, components,
classes, constructors, constants, and variables (attributes, parameters, data fields) that can be found in the
JavaFX 9 API. This is an impressive collection of seven Java 9 modules containing 36 packages, many of
which I outlined succinctly using tables and then covered one by one. I did this as most, if not all, of the
packages and classes outlined during this chapter will eventually be needed, in one way or another, for new
media, 2D, 3D, and hybrid 2D+3D pro Java 9 games development. When I say a comprehensive overview, I
mean let’s take a look at everything we’ll need for game development using JavaFX 9 under Java 9.
Certainly, I can’t cover every functional class in the JavaFX 9 API in one chapter, so I started with the
overview of the JavaFX API new media engine in Figure 7-1 and how it integrates with the JavaFX Scene
Graph above it and with the Java 9 APIs, NetBeans 9, and the target operating systems below these APIs.
Your Java 9 game distribution and the OSs are bridged using the Java Virtual Machine (JVM). This serves to
give JavaFX its expansive OS support across so many popular platforms and consumer electronics devices,
from smartphones to tablets to iTV sets, as well as all of the leading web browsers (Chrome, Firefox, and
Opera) that are based on the popular WebKit engine.
You took a high-level technical view of JavaFX by looking at the structures that make up your JavaFX
engine, including a JavaFX Scene Graph, the JavaFX APIs, Quantum, Prism, Glass, WebKit, and the
Media Player engine. You looked at how these multithreading, rendering, windowing, media, and web
engines interface with the Java 9 APIs and the JDK, as well as with NetBeans 9 and the JVM bytecode that
it generates, which is supported by all the various operating system platforms that are currently running on
top of more than a dozen different consumer electronics device types from 96-inch UHD iTV sets down to
4-inch smartphones.
I covered JavaFX core concepts, such as using the JavaFX Scene Graph, and the JavaFX pulse events
system, which we’ll be leveraging to create a pro Java 9 game throughout the course of the book, starting in
the next chapter, when we start to design the game and cover how to use the JavaFX Scene Graph to develop
the processing hierarchy.
I dove into some of the key JavaFX packages, subpackages, and classes used for pro Java 9 game design,
such as application, scene, shape, effect, layout, control, media, image, stage, animation, geometry, event,
fxml, and web, as well as their related Java 9 modules, packages, subpackages, classes, and subclasses. In
some cases, I even covered their interfaces, nested (helper) classes, and data constants.
You took a break from this JavaFX 9 API review to add some code to the JavaFXGame application that
allowed it to be a “windowless” application, which is able to “float” over any popular OS desktop. You
learned about how to make the Stage, Scene, and StackPane objects’ background attribute transparent by
using the alpha channel with a hexadecimal setting of 0x00000000 or by using the equivalent constant
representing 100 percent alpha transparency, such as Color.TRANSPARENT, StageStyle.TRANSPARENT, or
Background.EMPTY. You also saw that the Group (Node) class and object inherently have a transparent
background; when you changed your top-level Node for your Scene Graph from a StackPane to a Group
(a much better top-level Node), the Group background transparency did not need to be set at all.
I had to get some work using the NetBeans 9 IDE, the Java 9 programming language, and the JavaFX
9 API into this chapter, so we can start to gradually add more and more code until (soon) the remaining
chapters are completely coding, as all of this foundational material, covering new media asset design,
API, IDE, game concepts, JVM, UI, UX, 3D rendering engines, 2D playback engines, WebKit, static versus
dynamic, game optimization, and so forth, have all been put firmly into place in your minds, as you will need
to build upon this advanced knowledge throughout the duration of the book.

Free download pdf