For AI actors to interact with their environment realistically, they must make calculations that human players make naturally. One common interaction involves firing a projectile at a moving target.
Execute the following code:
@implementation Ch7_ProjectileAiming -(void) step: (ccTime) dt { [super step:dt]; /* CODE OMITTED */ //Firing projectiles fireCount += dt; if(fireCount > 1.0f){ fireCount = 0; [self fireMissiles]; } } /* Each enemy fires a missile object */ -(void) fireMissiles { for(int i=0; i<enemies.count; i++){ GameActor *enemy = [enemies objectAtIndex:i]; //Create missile GameMisc *missile = [[GameMisc alloc] init]; missile.gameArea = self; missile.tag = GO_TAG_MISSILE; missile.bodyDef->type = b2_dynamicBody; missile.bodyDef->position.Set( enemy.body->GetPosition...