Game Development Reference
In-Depth Information
Figure 14-13
.
Call a .setScaleX() method, off of the spriteFrame object variable reference, and pass it a -1 setting
value
Double-click on the
setScaleX(double value) void
option in the pop-up method se-
lector and then add the
-1
value, completing the method call. Now all PropH objects
will automatically have the Image asset Y axis mirrored! The final code for the PropH
constructor, once you add in the .setTranslateX() and .setTranslateY() method calls that
will actually position the fixed sprite location on the Stage, is seen in
Figure 14-14
,
and
looks like the following Java code:
import javafxscene.image.Image;
public class
PropH
extends
Actor
{
public PropH(String SVGdata, double
xLocation
, double
yLocation
, Image... spriteCels) {
super
(SVGdata,
xLocation
,
yLocation
, spriteCels);
this
.setIsFlipH(
true
);
spriteFrame.
setScaleX
(
-1
);
spriteFrame.setTranslateX(
xLocation
);
spriteFrame.setTranslateY(
yLocation
);
}
}