Multitouch bug in cocos2dx for marmalade

Multitouch bug in cocos2dx for marmalade
0.0 0



I started using cocos2dx and marmalade a while ago and ran into some problems when handling multitouch in my app. I found the cause and applied a quick fix which I will share with you so it can be fixed in a later version of cocos2dx for marmalade.

I’m using the following versions of cosos2dx and marmalade:
Marmalade 6.0.3

The problems is when one of multiple touches are ended, in that case ccTouchEnded() get called not just for the ended touch but for every active touch. This happens for ccTouchesEnded() as well, here the CCSet pTouches parameter includes all active touches and no clue about which touch has ended.

I tracked the problem down to the class CCEGLView in cocos2dx/platform/marmalade/CCEGLView_marmalade.h and cocos2dx/platform/marmalade/CCEGLView_marmalade.cpp.
The function setMultiTouch contains the following piece of code to handle ended touches:

m_pTouch->SetTouchInfo((float)event->m_x, (float)event->m_y); m_pDelegate->touchesEnded(m_pSet, NULL); m_pSet->removeObject(m_pTouch);

m_pSet is a CCSet containing all active touches. m_pSet is send to the touch dispatcher and is therefore dispatched to standard and targeted touch delegates. Hence all touches ends when one ends!

This can be fixed by just sending the ended touch, m_pTouch:

m_pTouch->SetTouchInfo((float)event->m_x, (float)event->m_y); CCSet ended; ended.addObject(m_pTouch); m_pDelegate->touchesEnded(&ended, NULL); m_pSet->removeObject(m_pTouch);

Touches moved and begin events are all handled the same way which could be a problem.


Thanks, I ’ll give it a try this weekend.