Game Development Reference
In-Depth Information
that the parameter list will pass in one or more Image objects. Your code will look like
the following:
public void Hero(String
SVGdata
, double
xLocation
, double
yLocation
, Image...
spriteCels
) {
super(
SVGdata
,
xLocation
,
yLocation
,
spriteCels
);
}
By using super() to pass your core constructor work up to the Actor superclass Act-
or() constructor method, your code that you wrote earlier, inside of the Actor() con-
structor, will create the
spriteBound
SVGPath Shape object using the Java
new
keyword and the
SVGPath
Shape subclass, and will uses a SVGPath class
.setCon-
tent()
method in order to load the SVGPath Shape object with your collision shape to
be used with the sprite image states. The
iX
and
iY
initial locations are set, and the
im-
ageStates
List<Image> array is loaded with sprite
Image
objects, passed in from the
end of the parameter list.
It's important to note that since we're setting this up in this way that the Hero class
has access to everything that the Actor class has (thirteen powerful attributes). Actu-
ally, it may be more “salient” to look at this the other way around, that the Actor (fixed
sprites) class has every capability that the Hero (motion sprites) class. This power
should be leveraged for level design wow factor, including multi-image states
(List<Image> Array), custom SVGPath collision shape capability, custom pivot point
placements, and the ability to flip (mirror) sprite imagery around either the X axis
(FlipV = true) or the Y axis (FlipH = true) or both axes (FlipH = FlipV = true). Putting
these capabilities into place in your Actor Engine (Actor and Hero abstract super-
classes) is only the first step; using them brilliantly for your game's design and pro-
gramming, as time goes on and you continue to build and refine the game, is the ulti-
mate goal for putting this foundation into place during this chapter. As you can see in
Figure 8-10
our basic (core) constructor code is error free.