cocos2d-x添加触摸
//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);
}