Q:

Cocos2d Sprite collision detection during action

I am unable to detect collision between two sprites, one moving in action.
I have a sprite of class "Enemy", moving across the screen via CCMoveTo, and another sprite of class "Hero", controlled by touch, both added onto a scene on class "MainGame"
The following indicates how the two sprites are added onto the scene and Enemy actioned:
MainGame.m
-(id) init{
if( (self=[super init]) ) {
    _enemies = [[NSMutableArray alloc]init];

    _enemyLink = [Enemy nodeWithTheGame:self];
    _enemyLink.position = ccp(10, 10);
    [self.enemies addObject:_enemyLink];
    CCMoveTo *test = [CCMoveTo actionWithDuration:40 position:ccp(500, 250)];
    [_enemyLink runAction:test];

    _heroArray = [[NSMutableArray alloc]init];
    _heroLink = [Hero nodeWithTheGame:self location:ccp(100,100)];
    [_heroArray addObject:_heroLink];

    [self scheduleUpdate];
    }
}

-(void)update:(ccTime)delta{

    if (CGRectIntersectsRect([self.enemyLink.enemySprite boundingBox], [self.heroLink.heroSprite boundingBox])) {
        NSLog(@"rect intersects rect");  
    }

    for (CCSprite *enemies in self.enemies) {
        NSLog(@"enemy position: %f, %f",enemies.position.x,enemies.position.y);
    }
}

I am unable to detect collision between these two sprites during and after the action. However if I move the Hero to the position on the scene (0,0) the log in my code will trigger, and the two will engage in attacks.
The for loop in the update indicates that the Enemy sprite position is constantly moving during the action. Hence why I am stumped as to why the collision is not being detected.

A:

Have you checked that both enemy and hero positions are tested within the same coordinates space? 
This is because boundingBox() is local, relative to its parent and if the nodes you compare do not have the same parent, the check will be invalid.
You can use convertToNodeSpace()/convertToWorldSpace() prior to checking bounding boxes.
Another answer that may be relevant to your case here: A sprite bounding box shows wrong position after moving the layer.

