Any body know how i just get 2 fingers touching the screen at the same time so i can drag a simple sprite around
I have made the jump to cocos2dx from cocos2d. I have been looking around all day trying to figure it out
Before I just used this code in cocos2d
-(void) ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
NSSet* allTouches = [touches setByAddingObjectsFromSet:[event touchesForView:[touch view]]];
NSArray* allTheTouches = [allTouches allObjects];
if ( [allTheTouches count] == 2 ) {
//Now Drag Something
//Around here.
}
}
In new project i have added
CCDirector::sharedDirector()->getTouchDispatcher()->addStandardDelegate(this, 0);
and found "touches->count();" but its always returns 0
void HelloWorld::ccTouchesMoved(CCSet* touches, CCEvent* event)
{
CCSetIterator it = touches->begin();
CCTouch* touch;
touches->anyObject();
CCPoint pt;
for( int iTouchCount = 0; iTouchCount < touches->count(); iTouchCount++ )
{
touch = (CCTouch*)(*it);
pt = touch->getLocationInView();
printf( "ccTouchesBegan id:%i %i,%i\n", touch->getID(), (int)pt.x, (int)pt.y );
if( touches->count() > 1 ) {
printf( "2 fingers id:%i %i,%i\n", touch->getID(), (int)pt.x, (int)pt.y );
}
it++;
}
}
Is there a bug in cocos2dx or dose anyone know how it is done or can translate the [allTheTouches count]
Im using cocos2d-x Ver 2.2.3, Mavericks 10.9.2 & Xcode
Thanks in advance.