Game Development Reference
In-Depth Information
Next let's create PropH , PropV , and PropB (which stands for “both”) classes.
These will automatically mirror props for us around the X, Y or X and Y axes using the
constructor method, so the object will inherently mirror images.
Mirrored Prop Classes: Set the isFlip Property in the
Constructor
To make our process of building scenes easier, since everything (collision, location, an-
imation) is part of a constructor method call, the difference between props is how they
are mirrored (X or Y axis, or both axes). In this section, we are going to create variants
of the Prop class that flip sprites for us, inside of a constructor method, so that all we
have to do to get the effect we want is create that PropX object type. Create the first
PropH class, as is shown in Figure 14-9 .
Figure 14-9 . Right-click on the project folder and select New
Java Class; using a New Java Class dialog, name
it PropH
Copy the contents of the basic Prop class that you created in the previous section,
including the package, import and super() constructor, into the PropH class, and then
change Prop to PropH , as is shown in Figure 14-10 .
 
 
 
Search WWH ::




Custom Search