Game Development Reference
In-Depth Information
There are one or two basic changes that we'll need to make in the InvinciBagel.java
class, before we switch over into the Bagel.java class to implement collision detection.
Since we are going to use the CastingDirector object in the collision code, we'll have
to remove the
private
access control keyword in the
CastingDirector
castDirector;
declaration, as shown in
Figure 16-28
. We are trying to keep as
many of the variables in our InvinciBagel class private as possible, and later make
them package protected if we need to access them from another class, such as Ba-
gel.java.
Figure 16-28
.
Remove the private access control modifier keyword for CastingDirector castDirector object declara-
tion
The next thing that we'll want to do is to remove the
iBagel
object from the
.ad-
dCurrentCast()
method call parameter list in the createCastingDirection() method. We
are doing this so that the InvinciBagel, who we are going to be checking for collision
against the rest of the Actor objects, which are contained in the
CURRENT_CAST
List<Actor>
object, does not check for collision against itself! The new shorter meth-
od call (minus the iBagel object) should look like the following Java code, which is
shown highlighted at the bottom of
Figure 16-29
:
castDirector.addCurrentCast(
iPR0, iPH0, iPV0, iPB0
);