i haves game with cocos2d i have many sprites i'm using touch to sprite with this
CGRectContainsPoint([[gameImages objectAtIndex:i] boundingBox], location)
CGPoint location = [touch locationInView: [touch开发者_运维百科 view]];
location = [[CCDirector sharedDirector] convertToGL: location];
but when i touched the sprite must be deleted i have
[self removeChild:[gameImages objectAtIndex:bacvacIndexner[0]] cleanup:YES];
but the touch works because i use the object coordinates and i cant delete object when i removin that from child what can i do?why i can get the touch event for sprite . are anything without coordinate method?
Use a callback so a higher class remove the object. Inside your to-be-removed class:
[self.touchDelegate performSelector:@selector(removeMe:) withObject:self afterDelay:0.0f];
精彩评论