Game Development Reference
Accordingly the shootBulletFrom method in the Bullet class implementation
has been extended to receive the isPlayerBullet parameter:
@synthesize velocity, isPlayerBullet;
. . .
self.velocity = vel;
self.position = startPosition;
self.visible = YES;
self.isPlayerBullet = playerBullet;
. . .
In the exact same fashion, the shootBulletFrom method in the BulletCache
class needs to be extended to receive the isPlayerBullet parameter and then pass
it on to the Bullet class. Both InputLayer and StandardShootComponent
make use of the shootBulletFrom method, and they need to pass in the isPlay-
erBullet parameter. The one in InputLayer sets it to YES , because that code is
responsible for shooting with the ship. The StandardShootComponent sets
isPlayerBullet to NO because the component is used for enemies.
The EnemyCache class holding all Enemy objects is the perfect place to call the new
collision-detection methods to check whether any enemy was hit by a player bullet.
The class has a new checkForBulletCollisions method, which is called from