Game Development Reference
In-Depth Information
Figure 10-2 . Create a New Java Class in the invincibagel package; name it CastingDirector for the InvinciBagel
Project
We will start by creating the List<Actor> ArrayList<Actor> objects first, one to
hold the current cast for your scene and then a second List<Actor> to hold objects to be
checked for collision detection. After that we will create the Set<Actor>
HashSet<Actor> object, which will provide an unordered Set object, which will col-
lect those Actor objects that need to be removed from the scene. Let's get started creat-
ing the body of our public CastingDirector class.
CreatinganArrayListObject:CURRENT_CASTData
Store List
The first thing that we need to add to the CastingDirector class is a private List<Actor>
ArrayList<Actor> object that I am going to name CURRENT_CAST as it contains the
Actor objects that are currently on the Stage, which is the current cast. Although it is
not technically a constant as far as using static and final keywords in its declaration, it
is acting (no pun intended) as a database of sorts, and so I am using ALL_CAPS so that
it stands out in the code as being a data structure. I'm also going to add a basic .get()
method to access the ArrayList<Actor> structure using a Java return keyword to re-
turn an object to the calling entity. The code for the declaration and instantiation of the
CURRENT_CAST ArrayList object and the body of the .getCurrentCast() method
structure should look like the following Java code:
 
Search WWH ::




Custom Search