JustinWong

做纯粹的快乐的游戏

导航

让CCLayer响应ccTouchBegan而非Touches

Posted on 2011-06-05 18:55  JustinWong  阅读(1676)  评论(0)    收藏  举报
In issue 652, a project member said:
Layer need to implement both methods: ccTouches and ccTouch.
The default one is ccTouches but you can modify the default behavior by overriding 
the "registerWithTouchDispatcher".

具体做法就是在CCLayer子类中增加如下代码:
-(void) registerWithTouchDispatcher {
    [[CCTouchDispatcher sharedDispatcher] addTargetedDelegate:self priority:0 swallowsTouches:YES];
}