Collision detection in 2D games is done using the
intersectsNode function of the sprite class itself. We can check whether the current sprite is overlapping the other sprite. In the
intersectsNode function of the current node, we pass in a node that we want to check for collision with the current node. If there is an intersection, the function will return
true, if not, it returns
For checking collision, we will first check the collision between the enemy's bullets and the hero. If there is collision, then the game is over. Then we will check collision between the hero's rockets and the enemies. If we detect a collision, then we have to update the score.
Also, if the enemy goes beyond the left of the screen, the game is ...