Game Development Reference
In-Depth Information
without implementing it (using it to create an actor). We will accomplish this by creat-
ing a Bagel.java class that will use the Java extends keyword to subclass a Hero.java
abstract class. This makes Bagel.java into a subclass, and makes Hero.java a super-
class.
Once we have a Bagel.java class in place, we will then use the Java new keyword
and the Bagel() constructor method for the Bagel class to create a Bagel object named
iBagel . We will load the iBagel object with some temporary SVG data, at least until we
get into how to create complex SVG collision shape data in Chapter 16 covering colli-
sion detection. We will also pass an X and Y coordinate, to put the iBagel actor in the
middle of the screen, and finally the 9-character movement sprite “cels,” which we first
looked at during Chapter 8 .
We will do this so you can start to utilize the primary data fields (variables, proper-
ties, or attributes) that we installed in a public abstract Actor and Hero class infrastruc-
ture, which we so painstakingly (or, should I say, lovingly) designed back in Chapter 8 .
We will also be working in our InvinciBagel.java primary application class again
here in Chapter 10 , and will create our iBagel Bagel (Hero) object in a new .cre-
ateGameActor() method we will be coding, so that we can wire our main character up
to the GamePlayLoop class's .handle() method. This will then access (call) the Bagel
class .update() method, so that we can start to control the movements for the primary
hero for our game, the InvinciBagel himself.
Game Design: Adding Our CastingDir-
ector.java class
The first thing that I want to do to is to update our invincibagel package and class
structure diagram to show you the new actor (sprite) management class that we are go-
ing to develop during this chapter using Java ArrayList and HashSet classes (objects).
As you can see in Figure 10-1 , I am going to name this class CastingDirector.java be-
cause it will act just like a Casting Director would for any entertainment project,
adding Actors to the project, and removing them when the scene is finished. This class
will also contain a Java collection (a Java ListArray is an ordered collection and a Java
HashSet is an unordered collection) that will be used when we start to implement colli-
sion detection later on during the topic. As your game levels and scenes get more com-
plicated, you will be glad to have a CastingDirector class that keeps your game actors
organized and adds and removes actors from the game as needed by your game's pro-
gramming logic. It is important to keep track of exactly how many Actor (fixed sprites)
 
Search WWH ::




Custom Search