Reputation: 234
Right now I have a NSMutableArray that holds 3 sprite objects. I need to be able to see if another sprite not in the Array shares the same position as any of the sprites in the array. I tried doing this:
CCSprite *sect;
if (i > maxHealth) {
for (int j = 0; j < i; j++) {
sect = [tail objectAtIndex:j];
}
if (CGRectContainsPoint(sect.boundingBox, playerPos)) {
NSLog(@"On top");
return;
}
But it does't work. I think it's trying to see if it intersects all of them at once.
Upvotes: 0
Views: 78
Reputation: 162722
Your if
is outside the for
loop. It is only going to test one object; the last one accessed in the loop.
Upvotes: 1