The CCTouchDispatcher
class is responsible for handling touches in Cocos2d. It can do it in the following two ways:
Standard: It acts as the CocoaTouch handler, where a set of touches is passed to the delegate and you may loop through them to act accordingly.
Targeted: It receives just one touch and can swallow touches to avoid propagation of the event. You should avoid propagation of touch events to the lower elements. It can be a horrible bug to track down if something is not working as expected.
The CCTouchHandler
class is responsible for handling the touches for a given CCNode. We will be using target touches for the Stone class. This means the Stone class will handle what happens when touched by itself. If we were using standard touches in the GameLayer, we would have to code a way for us to retrieve the stone we are touching.
In order for the stones to receive touch events, we must do two things:
First, we have to register the
stone
class to be able to receive...