I am trying to get a keyboard type of thing going with multitouch.
Even though I touch with two finger at separate positions, the same sprite is played.
Im sure it's something i've missed concerning the basics of touches.
- (void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
NSSet *allTouches = [event allTouches];
switch ([[allTouches allObjects] count]) {
case 1:
NSLog(@"One Touch");
UITouch *touch1 = [[allTouches allObjects] objectAtIndex:0];
CGPoint location1 = [touch1 locationInView: [touch1 view]];
location1 = [[CCDirector sharedDirector] convertToGL: location1];
for(int i=0;i<8;i++){
if(CGRectContainsPoint(xSprite[i].boundingBox, location1)){
[synthObject startNote:i];
}
}
break;
case 2:
NSLog(@"Two Touches");
UITouch *touch2 = [[allTouches allObjects] objectAtIndex:1];
CGPoint location2 = [touch2 locationInView: [touch2 view]];
location2 = [[CCDirector sharedDirector] convertToGL: location2];
for(int i=0;i<8;i++){
if(CGRectContainsPoint(xSprite[i].boundingBox, location2)){
[synthObject startNote:i+1];
}
}
break;
}
}