ccTouchBegan

CCLayer中的setTouchEnabled(true)会开启多点触摸
如果使用CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this,0,true);
只会开启一个点的触摸


当HelloWorld::ccTouchBegan返回为false的时候,TouchDispatcher将会相应下一个优先级的触摸代理。
bool HelloWorld::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent) {
return false;
}
,如果在HelloWorld中没有设置setTouchEnabled(true),将不会响应其他触摸,因为程序中没有其他的触摸代理了。

当HelloWorld::ccTouchBegan返回为true的时候,在界面上滑动就会调用HelloWorld::ccTouchMoved(CCTouch *pTouch, CCEvent *pEvent);

在CCLayer中,默认是没有开启触摸的,如果需要相应多点触摸事件,就必须setTouchEnabled(true)。
下面看看CCLayer中的setTouchEnabled,如果设置为true,就会以0为优先级来注册触摸监听代理,优先级的值越小,优先级越高,触摸响应是按照优先级来排列响应的。

原文地址:https://www.cnblogs.com/newlist/p/3208600.html