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 16 ■ Collision Detection: Creating SVG Polygons for the Game Actors and Writing Code to Detect Collision<br />

Figure 16-38. Add a period after object in the .remove() method to open method helper and select .getSpriteFrame()<br />

Place your cursor after the object reference that is inside of the .remove() method call that we are working on<br />

implementing, and type a period. This will bring up the attribute (property) and method helper pop-up, shown in<br />

Figure 16-38. Double-click on the getSpriteFrame() method, which we created back in Chapter 8, to call it off of the<br />

current Actor object which has been passed into the .collide() method. This will pass an ImageView Node object over<br />

inside of the .remove() method call, as expected, and the warning highlighting will also disappear, leaving clean code.<br />

As you can see in Figure 16-39, all of your <strong>Java</strong> code is error-free, and you have now played a sound, added this Actor<br />

object to the HashSet REMOVED_ACTORS data set, and removed the spriteFrame ImageView Node object for<br />

this Actor from the <strong>Java</strong>FX Scene Graph root (currently a StackPane layout container). We are now ready to remove this<br />

Actor object from the CURRENT_CAST List object, by using a .resetRemovedActors() method call.<br />

www.it-ebooks.info<br />

383

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

Saved successfully!

Ooh no, something went wrong!