Hamdullah shah
Hamdullah shah

Reputation: 804

Detect another touch while one finger is still on the screen

I want to detect a touch while one finger is still on the screen means that still touch canceled for that is not called... is it possible because i want to ignore that touch and perform operation on the next finger......

Thanks

Upvotes: 2

Views: 595

Answers (2)

sv_lane
sv_lane

Reputation: 3089

Also make sure multiple touch is enabled on the view, either through the multipleTouchEnabled property or the Multiple Touch checkbox in the storyboard editor.

Upvotes: 1

Ultrakorne
Ultrakorne

Reputation: 1303

- (void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

//those are all touches on this began call
    for (UITouch *touch in touches) {

        CGPoint location = [touch locationInView: [touch view]];
        CGPoint convertedLocation = [[CCDirector sharedDirector] convertToGL:location];

//those are ALL the touches on screen
 NSSet *allTouches = [event allTouches];

You can also keep track of touches by reading the hash code of the touch and saving it using int firstTouchHash = [touch hash].

You can check in the TouchesBegan if the touches set and the allTouches set have the same count (in this case we are touching the screen for the first time), in that case we can save the hash int firstTouchHash = [touch hash]

When we touch the screen again, the allTouches contains more elements than touches and we always know wich was the first touch because we have the hash saved. (without saving the hash, if we touch with 1 finger, then with a second one and then with a third, when the third touch occurs we dont know which of the 2 previous touches is the first, because they both are in the allTouches set (and a set is an unordered collection of elemenents) )

Upvotes: 1

Related Questions