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 - 1false);

}

posted on 2014-06-05 13:38  the seal  阅读(160)  评论(0编辑  收藏  举报