28.04.2019 Views

[JAVA][Beginning Java 8 Games Development]

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 4<br />

An Introduction to <strong>Java</strong>FX 8: Exploring<br />

the Capabilities of the <strong>Java</strong> 8<br />

Multimedia Engine<br />

Let’s build on the knowledge of the <strong>Java</strong> programming language that you gained in the previous chapter here in<br />

Chapter 4, by learning about the capabilities, components, and classes that make up the <strong>Java</strong>FX 8 multimedia engine.<br />

This amazing <strong>Java</strong>FX 8 API was added to <strong>Java</strong> 8 using the javafx package that you saw in Chapters 2 and 3, which was<br />

released with <strong>Java</strong> 8. The <strong>Java</strong>FX 8 package is significant to game programming because it contains advanced forms<br />

of classes that you will want to harness for game programming, including classes for organizing game components,<br />

using a scene graph; classes for user interface layout and design; classes for 2D digital illustration (also called vector<br />

graphics); and classes for digital imaging (also called raster graphics); 2D animation; digital video; digital audio; 3D;<br />

a web engine (WebKit); and much more, all of which I will be covering in this chapter, so that you know exactly what<br />

you have available to you, now that these <strong>Java</strong>FX 8 libraries have been added into the <strong>Java</strong> 8 programming language.<br />

The rationale for going into such detail is not only so that you know what <strong>Java</strong>FX 8.0 can do for your <strong>Java</strong> 8 game<br />

development, but also so that you have an overview of how the various components of this <strong>Java</strong>FX multimedia engine<br />

are put together. You will learn about the <strong>Java</strong>FX Quantum Toolkit, the Prism rendering technology, the WebKit web<br />

engine, the Glass Windowing Toolkit, the audio and video Media engine, and the Scene Graph API.<br />

The reason you will need this high-level overview of how <strong>Java</strong>FX works before you actually start to use it in your<br />

games is because it is a fairly complex set of APIs (I like to call it an engine). This is due to the power that it brings to<br />

implementing user interface (UI) and user experience (UX) “wins” in your <strong>Java</strong> 8 applications (in this case, games).<br />

So, bear with me in these foundational chapters detailing how to master your IDE (NetBeans 8.0), your programming<br />

language (<strong>Java</strong> 8), and this new media engine (<strong>Java</strong>FX 8) that is now a part of the <strong>Java</strong> 8 programming platform that is<br />

rapidly growing in power and popularity internationally.<br />

Once you have examined how <strong>Java</strong>FX 8.0 comes together at the highest level (just like you did in Chapter 3), you will<br />

consider some of those key classes that you might be using to construct <strong>Java</strong> 8 games, such as the Node class as well as<br />

the Stage, Scene, Group, StackPane, Animation, Layout, Shape, Geometry, Control, Media, Image, Camera, Effect,<br />

Canvas, and Paint classes. You have already studied the <strong>Java</strong>FX Application class (see Chapters 2 and 3), so now you<br />

will focus on the classes that can be used to build complex multimedia projects, such as <strong>Java</strong> 8 games.<br />

Finally, you will take an in-depth look at the bootstrap <strong>Java</strong>FX application that you generated in Chapter 2, and at<br />

how the <strong>Java</strong> .main() method and the <strong>Java</strong>FX .start() method create the primaryStage Stage object, using the Stage()<br />

constructor method, and, inside of that, create your Scene object named scene, using the Scene() constructor<br />

method. You will explore how to use methods from the Stage class to set the scene and title and show the Stage as<br />

well as how to create and use the StackPane and Button class (objects), and add an EventHandler to a Button.<br />

www.it-ebooks.info<br />

75

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!