Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cocos2d-x CCTouchDispatcher - no sharedDispatcher

I'm currently porting an ObjC cocos2d game to cocos2d-x, but I'm encountering some problems when trying to create a registerWithTouchDispatcher method, at the moment I'm doing

void GameLayer::registerWithTouchDispatcher()
{
    CCTouchDispatcher::sharedDispatcher()->addTargetedDelegate(this,0,true);
}

but this gives an error 'No member named sharedDispatcher' in cocos2d::CCTouchDispatcher'.

Is there another way that this must be done in cocos2d-x?

like image 930
Rory Harvey Avatar asked Jun 29 '12 15:06

Rory Harvey


2 Answers

If you are using 2.0, they have been merged in to CCDirector. please use

            CCDirector::sharedDirector()->getTouchDispatcher()
like image 126
m.ding Avatar answered Nov 18 '22 00:11

m.ding


use those code instead ccdirector. put the code to cclayer init function.

setTouchMode(kCCTouchesOneByOne);

registerWithTouchDispatcher();
like image 29
zszen Avatar answered Nov 17 '22 22:11

zszen