Game Development Reference
In-Depth Information
Figure 16-29 . Remove the iBagel object from the front of the list of objects passed into the .addCurrentCast() method
Now we are ready to start to put the methods into place in the Bagel.java class that
will check the iBagel object for collision against the objects which are in the
CURRENT_CAST List<Actor> object by checking the boundaries for each object's
Node (ImageView), and collision Shape (SVGPath). What we will be covering next
can get somewhat complicated, but if you want to really create a legitimate game title,
you need to be able to know when the game play elements intersect (called collide in
game development terminology) with each other. Let's dive into that Abyss now!
Bagel Class Collision Detection: .check-
Collision()
Right-click on the Bagel.java class in the Projects pane shown in Figure 16-29 and se-
lect the Open option and open up the Bagel.java tab in NetBeans 8. Go into the .up-
date() method, and comment out the playAudioClip() method call, using two forward
slashes at the beginning of the line of code. This will effectively turn off the audio for
the KeyEvent (KeyCode) KeyPressed constant call-outs that we have in place. The
reason I am doing this is because I am going to use this audio to “call out” a detected
collision in the code that we're about to create. Next, create a .checkCollision() meth-
 
Search WWH ::




Custom Search