Game Development Reference
In-Depth Information
Now that we have covered the final object variable issue, and shown you both ways
of dealing with it, let's continue on, and create a second ArrayList<Actor> object
named COLLIDE_CHECKLIST to store complex collision data.
Another ArrayList Object: COLLIDE_CHECKLIST
Data Store List
Now let's create our second List<Actor> ArrayList data store object and call it
COLLIDE_CHECKLIST since it will eventually be accessed in the .collide() method;
this will happen if you implement complex multiple object collision lists in later ad-
vanced stages of game development. We will not get to the advanced level that will re-
quire implementation of this during this topic, but I wanted to show you how to put a
complete CastingDirector class together, so that you will have it in place when you
need it for your game development, as you add more advanced features into your
game. This object will hold the most current copy of the CURRENT_CAST Ar-
rayList<Actor> and will have two methods. The .getCollideCheckList() method will
return the COLLIDE_CHECKLIST object, and the .resetCollideCheckList() will reset
the COLLIDE_CHECKLIST, by using the .clear() method call, and for now, we will
use the .addAll() method to load COLLIDE_CHECKLIST ArrayList<Actor> object
with the current version of the CURRENT_CAST ArrayList<Actor> object. Later we
can use this List to hold a custom collision checklist, that groups together only objects
that can collide with each other into one List. The Java code, which can be seen in Fig-
ure 10-7 , needed to declare and instantiate the object, should look like the following:
private final List<Actor> COLLIDE_CHECKLIST = new
ArrayList<>();
 
Search WWH ::




Custom Search