In my simple game I use boundingBox for pick coins and other stuff, but I need use irregular area detection of Sprite(with out Alpha)... There is alternative to boundingBox? Here is code:
-(void)ccTouchEnded:(UITouch *)touch withEvent:(UIEvent *)event {
CGPoint location = [touch locationInView:[touch view]];
CGPoint point = [[CCDirector sharedDirector] convertToGL:location];
curentPosition = point;
arrToDel = [[NSMutableArray alloc] initWithCapacity:0];
CCSprite *coin = nil;
for (Coins *coins in self.bugs) {
if (CGRectContainsPoint([coins boundingBox], curentPosition)) {
coin = coins; // found sprite
}
}
if (coin != nil) {
NSMutableArray *checkList = [NSMutableArray arrayWithCapacity:0];
for (Coins *coins in self.bugs) {
if (CGRectIntersectsRect([coin boundingBoxInPixels], [coins boundingBox]) && coins != coin) {
[checkList addObject:coins];
}
}
int max = coin.zOrder;
for (Coins *b in checkList) {
if (b.zOrder > max)
max = b.zOrder;
}
if (max == coin.zOrder) {
[self removeChild:coin cleanup:YES];
[arrToDel addObject:coin];
for (Coins *coins in arrToDel) {
[self.bugs removeObject:coin];
}
}
}
}