Ziem
June 16, 2013, 4:36pm
#1
Hello!
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)
{
CCLOG("ccTouchesBegan");
}
void SecondScene::ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent)
{
CCLOG("ccTouchesMoved");
}
void SecondScene::ccTouchesEnded(CCSet *pTouches, CCEvent *pEvent)
{
CCLOG("ccTouchesEnded");
}
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!
neno
June 16, 2013, 5:25pm
#2
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.
Ziem
June 16, 2013, 5:46pm
#3
Yes, I have:
this->setTouchEnabled(true);
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/proj.android/…/…/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp function:ccTouchBegan line:403
What is it?
neno
June 16, 2013, 5:52pm
#4
Probably you did override registerWithTouchDispatcher() and you should not override this method if you want to use ccTouches* methods.
Ziem
June 16, 2013, 6:09pm
#5
You are right ;). Thank you very much!
Removing ccTouch* methods and CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this, 0, true); solved my problem.