Game Development Reference
In-Depth Information
Figure 16-34 . Add Actor object that was passed into the .collide() method to parameter list of addToRemovedActors()
Not only do we need to remove this collided Actor object from the game cast using
the CastingDirector class (object), we also need to remove the ImageView Node from
the Scene Graph root as well. Let's look at how to do that next, and then we will take a
look at how to remove the Actor object from the CURRENT_CAST List<Actor> after
that.
Removing Actors from the Scene Graph: .getChil-
dren().remove()
Now that we have effectively removed the Actor that the InvinciBagel collided with
from the cast by adding it to the REMOVED_ACTORS HashSet<Actor> object, the
next step is to remove it from the JavaFX Scene Graph, which we are currently using
the StackPane UI layout container class for. If you remember earlier in the topic, we
learned that the StackPane class can be used as a layer-based layout container, and ar-
ranges its contents using a centered XY grid. We will be learning how to use a Group
object (class) as our Scene Graph root later on in the chapter, to implement the more
typical upper-left corner 0,0 XY location indexing scheme and as an optimization, as
we are not specifically using any of the StackPane class properties or methods, and be-
cause a Group class is a more basic class that is higher up in the Node superclass hier-
archy. In this way, you will have experienced using both center screen 0,0 location ref-
 
Search WWH ::




Custom Search