Game Development Reference
In-Depth Information
Figure 17-48 . Create loadBullet(), loadCheese() and loadEnemy() methods, to add another Enemy or Projectile to
game
Now that all these methods are in place, we can call them inside of the .initiateAt-
tack() auto-attack method body and put them to work checking to see if we need to add
a Projectile or Enemy object before we mount the next attack. The proper place to in-
voke these method calls would be after the Enemy object is onScreen, and the Pro-
jectile object has been launched, which means that these method calls need to go at the
end of the if(onScreen && launchIt) structure's else{} body of code. The Java code for
implementing these three method calls can be seen in Figure 17-49 , and should look
like the following:
if( onScreen && launchIt ) {
destination = 700;
if(spriteMoveR <= destination) {
spriteMoveR+=1;
spriteFrame.setTranslateX(spriteMoveR);
} else {
onScreen = false;
takeSides = true; // This will be false if
inside of the if(takeSides) structure
callAttack = false;
launchIt = false;
loadBullet();
loadCheese();
loadEnemy();
}
}
 
Search WWH ::




Custom Search