ccTouches* functions not getting triggered

ccTouches* functions not getting triggered
0.0 0


In my Android game I want to support multitouch but I don’t know why but ccTouches* functions aren’t triggered.

My SecondScene class extends CCLayer. In addition I override:

virtual void ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent);
virtual void ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent);
virtual void ccTouchesEnded(CCSet *pTouches, CCEvent *pEvent);

void SecondScene::ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent)

void SecondScene::ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent)

void SecondScene::ccTouchesEnded(CCSet *pTouches, CCEvent *pEvent)

Functions like: ccTouch* or didAccelerate work fine. I’m using: cocos2d-2.1rc0-x-2.1.2 @Mar.20 2013.
What I am doing wrong?

Thanks in advance!


Do you have setTouchEnabled(true); in your layer’s init() method? Also I’m not sure if you can mix ccTouches* with ccTouch* methods so maybe you should try one approach at once first.


Yes, I have:

I also removed all ccTouch* methods and it doesn’t solve my problem. In addition now when I touch the screen I’m getting assert error:

E/cocos2d-x assert(3420): C:/cocos2d-x-master/Tasss/…/…/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp function:ccTouchBegan line:403

What is it?


Probably you did override registerWithTouchDispatcher() and you should not override this method if you want to use ccTouches* methods.


You are right ;). Thank you very much!

Removing ccTouch* methods and CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this, 0, true); solved my problem.