1

In my cocos2dx game, I have a CCLayer that contains another CCLayer. The sublayer just cover part of the container layer. I 'think' I achieve this through:

this->setContentSize( CCSizeMake( 100, 200 ) );

however, the sublayer always capture touches even though it is outside its size and position area... Is it common?

I can filter through the touches position by comparing it inside the ccTouch** functions, but I think it is a hack, what is the proper way to set the sublayer to properly cover just the partial area of its parent?

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
Zennichimaro
  • 5,236
  • 6
  • 54
  • 78

1 Answers1

0

The only thing i can think of straight away is making this inner layer a CCNODE and also extent it with CCTouchDelegate. Now with this, when u register with the TouchDispatcher, you make sure it doesn't Swallowtouches(the boolean value given as the last parameter)... This way when you receive a touch ... just see if it is within the boundary of this inner layer of urs and if it is not, send let the parent class use this touch.

Hope this helps.

Syed Mauze Rehan
  • 1,125
  • 14
  • 31