Game Development Reference
In-Depth Information
Mesh
superclass and its
TriangleMesh
subclass handle 3D geometry, as do the
Shape3D
superclass and its
Box
,
Sphere
,
Cylinder
, and
MeshView
subclasses. The
Shape
superclass has many more subclasses (11); these are 2D geometry elements and
include the
Arc
,
Circle
,
CubicCurve
,
Ellipse
,
Line
,
Path
,
Polygon
,
Polyline
,
QuadCurve
,
Rectangle
, and
SVGPath
classes. A path support, a path being defined
as an open shape (I like to call it a spline, as I am a 3D modeler), is also supplied by the
PathElement
superclass and its
ArcTo
,
ClosePath
,
CubicCurveTo
,
HLineTo
,
LineTo, MoveTo, QuadCurveTo, and VLineTo subclasses, which allows you to draw
spline curves to create your own custom shapes!
The
javafx.scene.text
subpackage has classes for rendering text shapes and fonts
into your scenes. This includes the
Font
class, for employing any fonts that you may
want to use that are not a JavaFX system font, as well as the
Text
class, for creating a
text node that will display the text values using this font. There is also a specialized
layout container class, called
TextFlow
, which is used to flow text, much like you
would see done on a word processor.
The
javafx.scene.transform
subpackage offers classes for rendering 2D and 3D
spatial transformations
, such as the
Scale
,
Rotate
,
Shear
,
Translate
, and
Affine
(3D
rotation) subclasses of the
Transform
superclass. These can be applied to any Node
object in the Scene Graph. This allows anything in your scene graph (text, UI controls,
shapes, meshes, images, media, and so on) to be transformed in any way that you like,
which affords JavaFX game developers a ton of creative power. In case you are won-
dering, translation is linear movement of an entire object; shear is linear movement on
a 2D plane in two different directions or movement in one direction when another part
of the 2D plane is fixed. Imagine moving the top of a plane, while the bottom remains
fixed, such that the square becomes a parallelogram, or moving the top and bottom of
the same plane (a square) in different directions.
The
javafx.scene.web
subpackage furnishes classes for rendering web assets into a
scene, using a collection of classes, including
WebView
,
WebEvent
,
WebEngine
,
WebHistory
, and
HTMLEditor
. The WebEngine (see, other people call things en-
gines as well) class, as you might imagine, does the processing for showing HTML5 +
CSS3 + JS in JavaFX, and the WebView class creates the node for displaying the We-
bEngine output in the Scene Graph. The WebHistory class (object, ultimately) holds
the session history (from WebEngine instantiation to removal from memory) for the
web pages visited, and WebEvent bridges the JavaScript web event processing with the
JavaFX event processing.
Now that you have looked at a plethora of important and useful classes (objects) in
the javafx.scene package and its related subpackages, let's take a look at the 15 top-
level JavaFX packages to get a better idea of the key capabilities that JavaFX offers for