Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1
Chapter 17 ■ i3D Game Square SeleCtion: uSinG the piCkreSult ClaSS with 3D moDelS

We have added some fairly complex functionality during this chapter, and we are still at around 500
lines of Java code, as you can see at the bottom of NetBeans 9 in Figure 17-18 (the end of the class at line
504). Very impressive, folks!


Summary


In this seventeenth chapter, we learned about the MouseEvent, PickResult, and Random classes, which
allow us to finish implementing our 3D spinner UI and have it select a random quadrant on each subsequent
spin of the spinning 3D spinner beach ball. We also constructed a new custom createSceneProcessing()
method that contains your MouseEvent handling logic, as well as your logic for processing the (now) i3D
primitive objects that our i3D game board and spinner is comprised of (built with). Inside this new method,
we began building a conditional if() structure to evaluate mouse clicks and what needs to happen with the
game logic based on what is clicked. We will obviously be expanding this logic as we design and develop our
gameplay model over the next several chapters.
We also got some more experience using the RotateTransition class methods by converting your
rotSpinner and rotGameBoard Animation objects from using .setFromAngle() and .setToAngle() rotation
animation configuration parameters to a single .setByAngle() rotation animation configuration approach,
reducing our lines of Java code by 12.
In Chapter 18 , we are going to develop your game content so that we can finish your MouseEvent
handling code (during Chapters 19 and 20 ) for the game board squares and the game board quadrants.


Figure 17-19. The game board randomly lands on a different quadrant, and the spinner always lands on the
word SPIN

Free download pdf