Fan Wang wrote:
But the android sdk can return all touches at 1 time. and if the cocos2d implements the touch by JNI , the cocos2d should be able to do it too.
cocos2d doesn’t implement everything the native implementations allows, for various reasons (doesn’t really fit in, can’t be done on other platforms etc…). If you have a specific need, by all mean implement it yourself. It’s pretty straightforward, from begin and end events, to reconstruct an array of active touches.
Indeed the 2 touches is not at the exactly same time, And it will cause 1 problem by using current ccTouchesBegan: There will be touchesMoved between the 1st and 2nd touch even if I actually want to do multi touch. unless remembering the touches’ time as Leszek said, how to recognize the 1st moved is an actual move or just a meaningless move ?
There are 2 variables you should check if you want to detect “2 tap at the same time” : the time at which the touch did begin, and the total movement since the beginning. You’ll have to do that yourself, since cocos2d, as far as I know, doesn’t have any gesture recognizer.
For the total movement, I advise to add ccpDistance(position, previousPosition) to a distance counter associated to the touch. Some good values would be a maximum of 0.5 sec and a maximum of 50 pixels total movement after which a touch is discarded as a possible tap.
Hope this helps.