//CCLayer
//CCTouchDelegate
bool CBattleLayer::init()
{
if( ! CCLayer::init() )
{
return false;
}
this->setTouchEnabled( true );
return true;
}
void CBattleLayer::onEnter()
{
CCDirector * pDirector = CCDirector::sharedDirector();
pDirector->getTouchDispatcher()->addTargetedDelegate(this, touchlevel - 1, false);
CCLayer::onEnter();
}
void CBattleLayer::onExit()
{
CCDirector* pDirector = CCDirector::sharedDirector();
pDirector->getTouchDispatcher()->removeDelegate( delagate );
CCLayer::onExit();
}
//CCLayer
void CScrollView::registerWithTouchDispatcher()
{
CCDirector * pDirector = CCDirector::sharedDirector();
pDirector->getTouchDispatcher()->addTargetedDelegate(this, touchlevel - 1, false);
}
原文地址:http://www.cnblogs.com/sealme/p/3770172.html