Game Development Reference
In-Depth Information
Figure 14-15
.
A completed PropV() constructor method creates a fixed PropV object flipped along the vertical Y axis
Next, perform the same work process that you did for the PropV class, and create
the
PropB
class. This class will set
both
the
isFlipV
and
isFlipH
properties to
true
,
and implement a
spriteFrame.setScaleX(-1);
method call, as well as a
spriteFrame.setScaleY(-1);
method call. Your Java class structure for this
last PropB class, which will mirror fixed prop imagery along both an X and Y axis, can
be seen in
Figure 14-16
and will look like the following code:
public class
PropB
extends
Actor
{
public PropB(String SVGdata, double
xLocation
, double
yLocation
, Image... spriteCels) {
super
(SVGdata,
xLocation
,
yLocation,
spriteCels);
this.
setIsFlipH
(
true
);
spriteFrame.
setScaleX
(
-1
);
this.
setIsFlipV
(
true
);
spriteFrame.
setScaleY
(
-1
);
spriteFrame.setTranslateX(
xLocation
);
spriteFrame.setTranslateY(
yLocation
);
}
}