So I set up my game like this. I have a CCLayer called MainLayer. I added a child layer in the MainLayer called GameLayer. Then I added another child layer in the MainLayer called HUDLayer. So MainLayer contains GameLayer and HUDLayer. Now, I want to add touch events and do the following:
- Tap an object in the GameLayer and have that object do something.
- Tap an object in the HUDLayer and have that object do something.
- Drag an object in the GameLayer and move it into the HUDLayer.
- Drag the GameLayer so that it shows more of the layer.
I was able to do 1, 2, and 3 but all the objects are on the MainLayer and I wanted to implement layers so that each type of object (HUD objects in the HUDLayer and game objects in the GameLayer) is in their respective layers.
My guess is that I have to add touch handlers ( ccTouchBegan, ccTouchMoved, ccTouchEnded ) in GameLayer and HUDLayer but I am not sure how to add touch events on the child layers.
Any help?
EDIT Another solution I can think of is to make a new class that subclasses CCLayer.