Hi need help,
I have 3 sprites overlapped, with tag 1 to 3. How i can remove multiple overlapped sprite in a single touch?
I have a loop code below to remove sprite based on tag, its not working. All im getting is that i need to click the same spot 3 times to remove the 3 sprites.
-(void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch* myTouch = [touches anyObject];
CGPoint location = [myTouch locationInView: [myTouch view]];
location = [[CCDirector sharedDirector]convertToGL:location];
location = [self convertToNodeSpace:location];
int totalNumberOfItems=4;
for (int y=0; y < totalNumberOfItems; y++){
CCSprite *temp = (CCSprite*)[self getChildByTag:y];
CGRect test1 = [temp boundingBox];
if (CGRectContainsPoint(test1, location)) {
NSLog(@"touched");
[self removeChild:temp cleanup:YES ];
return;
}
}
}