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-39. Remove the currently collided with Actor object ImageView Node from the Scene Graph using .remove()<br />

After we update the CURRENT_CAST List, we will have done our basic collision management coding, and we can<br />

take a look at how we can optimize the .checkCollision() and .collide() methods to work together more efficiently.<br />

Reset the Removed Actor List: .resetRemovedActors() Method<br />

The final thing that we need to do in the series of programming statements that need to happen when a collision<br />

occurs is to reset the REMOVED_ACTORS HashSet object. As you recall from Chapter 10, this method<br />

removes the removed actors from the CURRENT_CAST List object, so that the Actor object is completely<br />

removed from the game entirely. Besides the .playiSound0() method call we are using to test this method using our<br />

ears, this is one of the simplest <strong>Java</strong> programming statements that we will have to code, and should look like the<br />

following <strong>Java</strong> code:<br />

invinciBagel.castDirector.resetRemovedActors();<br />

384<br />

www.it-ebooks.info

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

Saved successfully!

Ooh no, something went wrong!