0

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.

stenger96
  • 224
  • 3
  • 17

1 Answers1

1

Your if is outside the for loop. It is only going to test one object; the last one accessed in the loop.

bbum
  • 162,346
  • 23
  • 271
  • 359