void HelloWorld::onEnter() { CCLayer::onEnter(); CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this,0,false); } void HelloWorld::onExit() { CCLayer::onEnter(); CCDirector::sharedDirector()->getTouchDispatcher()->removeAllDelegates(); } bool HelloWorld::ccTouchBegan(CCTouch *pTouch,CCEvent *pEvent) { CCLOG("began"); return true;//返回true表示可以接受接下来的事件 } void HelloWorld::ccTouchMoved(CCTouch *pTouch,CCEvent *pEvent) { CCLOG("move"); } void HelloWorld::ccTouchEnded(CCTouch *pTouch,CCEvent *pEvent) { CCLOG("end"); } //这个不常用 void HelloWorld::ccTouchCancelled(CCTouch *pTouch,CCEvent *pEvent) { CCLOG("cancell"); }