Game Development Reference
In-Depth Information
tion of takeSides and bulletType. The last two conditional if() structures should look
like this:
if(
bulletType
&&
!takeSides
) {
invinciBagel.
iCheese
.spriteFrame.setTranslateY(randomOffset);
invinciBagel.
iCheese
.spriteFrame.setScaleX(-0.5);
invinciBagel.
iCheese
.spriteFrame.setScaleY(0.5);
bulletRange = -50;
if(bulletOffset >= bulletRange) {
bulletOffset-=4;
invinciBagel.
iCheese
.spriteFrame.setTranslateX(bulletOffset);
} else { shootBullet = false; }
}
if(
bulletType
&&
takeSides
) {
invinciBagel.
iCheese
.spriteFrame.setTranslateY(randomOffset);
invinciBagel.
iCheese
.spriteFrame.setScaleX(0.5);
invinciBagel.
iCheese
.spriteFrame.setScaleY(0.5);
bulletRange = 624;
if(bulletOffset <= bulletRange) {
bulletOffset+=4;
invinciBagel.
iCheese
.spriteFrame.setTranslateX(bulletOffset);
} else { shootBullet = false; }
}
Tweaking a Game: Fine-Tuning the User
Experience
Let's take a moment and make a couple of adjustments to the code now that the auto-
attack logic is working, to make sure that our game play is professional. Place the
iBeagle, iBullet, and iCheese objects off-screen at game start-up, by changing the X
and Y location parameters in each of these object's constructor methods with negative
X location values that are the same as (or greater than) the width of the sprite image as-
set, as can be seen in
Figure 17-52
.