Game Development Reference
In-Depth Information
form that is rendering the game. In addition, if you set it up correctly, you can use the
lighting classes with your 2D games or use lighting with a hybrid 2D-3D game.
The Camera class, and its ParallelCamera and PerspectiveCamera subclasses,
can be used to photograph or video your scene in 3D and 2D (and hybrid) game applic-
ations. Two of the camera classes, Camera and ParallelCamera, do not require that 3D
(GPU) capabilities be present on the platform that is playing your JavaFX application
(in this case, a game).
The subclasses of the Camera class provide two different, specialized types of cam-
eras. The ParallelCamera class can be used for rendering scenes without any depth per-
spective correction, which in the 3D industry is called an orthographic projection .
What this means is that this class is perfect for use with 2D scenes (and for 2D games).
The PerspectiveCamera class has a much more complex camera, used for 3D
scenes, which will support 3D viewing volumes. Like the LightBase class and its sub-
classes, the PerspectiveCamera class requires 3D capabilities on the hardware platform
that the application (or game) is running on.
The PerspectiveCamera class has a fieldOfView attribute (state or variable), which
can be used to change its viewing volume, just like a real camera zoom lens, when you
zoom it in from wide angle. The default setting for the fieldOfView attribute is an acute
angle of 30 degrees. If you remember your geometry from high school, you can visual-
ize this field of view by looking down the y (vertical) axis at the camera. As you might
expect, there are .getFieldOfView() and .setFieldOfView(double) method calls to
control this camera class attribute.
Next, let's take a closer look at the Scene utility classes. After that, you will exam-
ine some of the javafx.scene subpackages , such as javafx.scene.text,
javafx.scene.image, javafx.scene.shape, and javafx.scene.layout.
JavaFX Scene Utilities: Scene Snapshots and Antiali-
asing
Finally, you should take a quick look at the three utility classes, shown in the right-
hand column in Figure 4-2 , as they can be used to improve the quality of scene output
on the user's device's screen (using antialiasing) as well as to provide screen capture
capabilities to either your user (for social media sharing) or your game play logic itself.
Let's investigate the SceneAntialiasing class first. Antialiasing is a digital imaging
industry term that references an algorithm that smoothes jagged edges where two col-
ors come together, usually on a diagonal line or in the circular area of an image com-
posite. An image composite is two separate images placed in layers to form one im-
Search WWH ::




Custom Search