0
votes

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?

1
Your question is poorly written. Whether you dont speak English natively or do, please revise it to make more sense.user481081
Sorry, I have to agree with @Sold Out Activist. I feel I am very close to understanding your question, but not quite enough to actually answer it.Aaron Goselin

1 Answers

1
votes

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];