벽에 충돌했는지 확인할 수 있도록 Sprites를 추가하려는 NSMutable 배열이 있습니다. 나는 그렇게 할이 코드를 사용합니다. 'HELP'나는 구축하고 실행할 때nsmutablearray가 호출 될 때 객체를 추가하지 않음
NSString *bulletName = [NSString stringWithFormat:@"tank%d_bullet.png", _type];
bullet = [CCSprite spriteWithSpriteFrameName:bulletName];
bullet.tag = _type;
bullet.position = ccpAdd(self.position, ccpMult(_shootVector, _turret.contentSize.height));
CCMoveBy * move = [CCMoveBy actionWithDuration:duration position:actualVector];
CCCallBlockN * call = [CCCallBlockN actionWithBlock:^(CCNode *node) {
[node removeFromParentAndCleanup:YES];
}];
if (!bulletIsGone) {
[self schedule:@selector(updator:) interval:0.01];
}
else {
[self unschedule:@selector(updator:)];
}
[bullet runAction:[CCSequence actions:move, call, nil]];
[_layer.batchNode addChild:bullet];
[bulletsArray addObject:bullet];
if ([bulletsArray objectAtIndex:0] == nil) {
NSLog(@"HELP");
}
NSLog(@"%@", [bulletsArray objectAtIndex:0]);
}
-(void)updator: (ccTime) dt{
for(CCSprite *bulletz in bulletsArray){
NSLog(@"this is the for loop");
CGRect rect1 = CGRectMake(bulletz.position.x - bulletz.contentSize.width/2, bulletz.position.y - bulletz.contentSize.height/2, 20, 20);
if ([_layer isWallAtRect:rect1]) {
NSLog(@"bulletHitWall");
[_layer.batchNode removeChild:bulletz cleanup:NO];
bulletIsGone = YES;
}
}
}
그러나, 나는 '(널)'과의 콘솔 출력을 얻을 'updator'이전의 메소드는 touchesEnded에서 호출됩니다. 누군가 내가 잘못하고있는 것을 볼 수 있습니까? 감사합니다.
** facepalm ** 감사 : / – Jeeter