28.04.2019 Views

[JAVA][Beginning Java 8 Games Development]

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 17 ■ Enhancing Game Play: Creating a Scoring Engine, Adding Treasure and an Enemy Auto-Attack Engine<br />

Figure 17-51. Add bulletType to conditional if statement evaluation in shootProjectile() method, to shoot cream cheese<br />

Next we need to do the same conversion for the bulletType equals true value. This will signify use of Cream<br />

Cheese as a Projectile object type. Once we put these conditional if() structures into place, we’ll have one if() structure<br />

for each logical combination of takeSides and bulletType. The last two conditional if() structures should look like this:<br />

if(bulletType && !takeSides) {<br />

invinciBagel.iCheese.spriteFrame.setTranslateY(randomOffset);<br />

invinciBagel.iCheese.spriteFrame.setScaleX(-0.5);<br />

invinciBagel.iCheese.spriteFrame.setScaleY(0.5);<br />

bulletRange = -50;<br />

if(bulletOffset >= bulletRange) {<br />

bulletOffset-=4;<br />

invinciBagel.iCheese.spriteFrame.setTranslateX(bulletOffset);<br />

} else { shootBullet = false; }<br />

}<br />

if(bulletType && takeSides) {<br />

invinciBagel.iCheese.spriteFrame.setTranslateY(randomOffset);<br />

invinciBagel.iCheese.spriteFrame.setScaleX(0.5);<br />

invinciBagel.iCheese.spriteFrame.setScaleY(0.5);<br />

bulletRange = 624;<br />

if(bulletOffset

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!