I'm sure you're now an expert at managing collisions, so I think we should detect collisions between our scientist hero and the spaceships or the game will lack realism.
Try to detect these collisions so we can't fly over the whole airspace and make the scientist blink as we did with the yeti in the previous chapter.
To achieve this challenge, you will need to take advantage of detectCollisions
. How it's built makes our task very easy. As we want to detect collisions with UFOs, we will include our code inside the _arrayUFOs
loop, and the best place is after this line:
[_arrayLaserGreen removeObjectsInArray:_lasersGreenToRemove];
Paste the following block of code there:
// Detect ufo-scientist collision if (CGRectIntersectsRect(ufo.boundingBox, _scientist.boundingBox)) { // Blink actions for both fire and scientist CCAction *actionDrBlink = [CCActionBlink actionWithDuration...