Game Development Reference
In-Depth Information
Figure 14-11 . Add a Java this keyword reference to PropH (object) inside of the constructor and open up method
helper
Double-click on the .setIsFlipH method, shown highlighted in Figure 14-11 , and
insert a true value inside the method call parameter area. The finished
this.setIsFlipH(true); Java statement can be seen in Figure 14-12 .
Figure 14-12 . Call the .setIsFlipH() method, off of a Java this (PropH) object reference, and pass it the true setting
value
It is important to note that if we only use the this.setFlipH(true); method
invocation in the constructor method, we would still need to observe that isFlipH is set
this way, and invoke your .spriteFrame.setScaleX(-1); method call, some-
where else in the code. Let's go ahead and put this method call in your constructor
method as well, so that all our PropH objects automatically will have their Image assets
flipped around the Y axis. In case you might be wondering why the .setScaleX(-1)
method mirrors the Image asset around the Y axis, that is something that I was also
wondering about, but what I did was match the isFlipH with the .setScaleX(-1) (since
X is an H or horizontal axis). That said, I would have made .setScaleY(-1) mirror
around the vertical Y axis, which makes more sense to me. Add another line of code
and type spriteFrame and hit the period key, and select .setScaleX in the pop-up, as
seen in Figure 14-13 .
 
 
 
Search WWH ::




Custom Search