cocos2d-x CCTouchDispatcher - no sharedDispatcher
Asked Answered
M

3

10

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?

Merriment answered 29/6, 2012 at 15:2 Comment(0)
U
19

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

            CCDirector::sharedDirector()->getTouchDispatcher()
Urba answered 29/6, 2012 at 23:40 Comment(1)
CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this, 0, true); - add the rest of itGhat
K
1

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

setTouchMode(kCCTouchesOneByOne);

registerWithTouchDispatcher();
Komsa answered 26/5, 2013 at 16:57 Comment(0)
M
0

In the cocos2d-x you can do like this.

CCDirector::sharedDirector()->getTouchDispatcher()->addStandardDelegate(this,0);
Moyna answered 5/12, 2013 at 11:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.