1-star challenge: check collisions accurately

We learned how to detect collisions thanks to the intersects method provided by CGRect, but in this way, the collision will be triggered as soon as the rabbit's ears touch the doors. Let's add another condition to the if statement in detectCollisions in order to take into account the rabbit's and door's frame position. Thus, the collision will only happen when the door reaches half the rabbit's frame. As shown in the following screenshot:

1-star challenge: check collisions accurately

Solution

This challenge is very easy and I hope you were able to solve it. To perform this check, you just need to add the following condition to the if statement:

&& ...

Get Getting Started with SpriteKit now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.