28.04.2019 Views

[JAVA][Beginning Java 8 Games Development]

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 16 ■ Collision Detection: Creating SVG Polygons for the Game Actors and Writing Code to Detect Collision<br />

objects, but only after we use the Run ➤ Project work process to see exactly how using a Group differs from using a<br />

StackPane. After all, it’s all about learning how these classes work! The <strong>Java</strong> code for changing a StackPane object’s<br />

import, declaration, and instantiation into a Group object should look like the following <strong>Java</strong> code, which is also shown<br />

in Figure 16-42:<br />

import javafx.scene.Group;<br />

public class InvinciBagel extends Application {<br />

Group root;<br />

public void start(Stage primaryStage) {<br />

root = new Group();<br />

// replaced StackPane import with Group<br />

// all other object declarations omitted<br />

// all other object instantiations omitted<br />

Figure 16-42. Replace the StackPane UI container with the Group (Node subclass) import, declaration and<br />

instantiation<br />

After you make these changes and Run ➤ Project, you’ll see the result shown on the left half of Figure 16-43. The<br />

game is now using an upper-left 0,0 origin, so we’ll have to modify the rest of the existing code. Let’s do that now.<br />

www.it-ebooks.info<br />

387

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

Saved successfully!

Ooh no, something went wrong!