Game Development Reference
In-Depth Information
} else { shootBullet = false ; }
}
if( takeSides ) {
invinciBagel.iBullet.spriteFrame.setTranslateY( randomOffset );
invinciBagel.iBullet.spriteFrame.setScaleX( 0.5 );
invinciBagel.iBullet.spriteFrame.setScaleY( 0.5 );
bulletRange = 624 ;
if( bulletOffset <= bulletRange ) {
bulletOffset+=4 ;
invinciBagel.iBullet.spriteFrame.setTranslateX( bulletOffset );
} else { shootBullet = false ; }
}
}
Figure 17-43 . Add private void shootProjectile() method and code the if(!takeSides) and if(takeSides) if-else state-
ments
If you now use your Run Project work process you will see your iBeagle anim-
ate on screen, shoot a bullet, and retreat quickly back off-screen. The next level of real-
ism that we need to add into our code is to have the iBeagle pause for a second while
he aims and shoots the bullet, because currently it looks like he is hitting an invisible
barrier and bouncing back off-screen. We will do this by adding counter logic into the
if(shootBullet) conditional statement in the .update() method. Let's do that next, so that
we have a completely professional Enemy auto-attack sequence!
 
Search WWH ::




Custom Search