In the contact delegate’s didBeginContact
function, we make use of the physics bodies’ category bit masks to ensure that only collisions between balloon nodes trigger explosions (that is, nodes of the BalloonCategory
.). We use the bitwise AND operator to determine whether both bodies are of BalloonCategory
, and run the action only if they are.
And finally...
Playgrounds provide you with a way to experiment with your code that is interactive and fun. Playgrounds are also rewarding, because you learn by doing and by making mistakes in a controlled environment. More important, they challenge your curiosity and encourage you to play with and test your code while writing it.
Have fun! Change the code, experiment, and don’t be afraid to start over.