Game Development Reference
In-Depth Information
Figure 4-7
.
Run the project to look at the transparent Stage object; something is still set to White
Because you are using a
StackPane
object to implement layers in the InvinciBagel
application, this is the next level up that you need to try to set a transparency value for.
Evidently, JavaFX uses a Color.WHITE default background color value for all its ob-
jects. If I were on the JavaFX design team, I would be arguing for this to be changed to
the Color.TRANSPARENT constant, but, of course, this might confuse new users, as
alpha channel and compositing layers are advanced concepts.
The
javafx.scene.layout.StackPane
class is subclassed from the
javafx.scene.layout.Region
class, which has a
.setBackground()
method for setting
the
Background
(class or object) value. Again, a TRANSPARENT value constant
must be available, as you always need to set background values as transparent, espe-
cially for Java 8 game design.
Interestingly, things are not always as straightforward and consistent as you would
want them to be in Java programming, as, to achieve exactly the same end result (in-