Game Development Reference
In-Depth Information
Now we're ready to add the Java code that manages the CastingDirector object, to
remove the Actor object.
If Collision Detected: Manipulating the CastingDirect-
or Object
Add a line of code under the .playiSound0() method call, accessing the CastingDirector
object,
invinciBagel.castDirector
. Next type a
period
key, to access a method helper
pop-up, seen in
Figure 16-33
, and select
.addToRemovedActors()
.
Figure 16-33
.
Add a line of code under the .playiSound0() method call, and type invinciBagel.castDirector, and a
period
After you double-click on the
.addToRemoveActors(Actor… actors)
option in
this pop-up helper dialog, you will need to pass the Actor object, aptly named
object
,
into the method call using the parameter list area inside of the parentheses, as shown
highlighted at the bottom of
Figure 16-34
.
This will add this Actor object that was just
involved in a collision (luckily, no one was hurt) to the REMOVED_ACTORS
HashSet<Actor> object.