My game keeps crashing around this particular block of code.
The error message is Thread1: EXC_Bad_ACCESS(code =1)
and the highlighted code is the following:
-(void)updateForArrays:(ccTime)delta
{
for (CCSprite *child in [self children]){
if (child.tag==2) {
if (CGRectIntersectsRect(child.boundingBox, _ship.boundingBox)) {
[self removeChild:child cleanup:YES];
_score += 1;
[_scoreLabel setString:[NSString stringWithFormat:@"Score : %d",_score]];
}
}if (child.tag ==3){
if (CGRectIntersectsRect(child.boundingBox, _ship.boundingBox)) {
CCScene *gameOverScene = [GameOverLayer gameOverScene];
[[CCDirector sharedDirector] replaceScene:gameOverScene];
}
}
}
}