В моем коде есть два класса, связанных с Bullet. Пуля и BulletCache. BulletCache создает определенное количество
Я перешел к простому созданию нового метода создания пуль, предназначенного для стрельбы пулями. Я использовал метод CCFuncN, но в настоящее время игра выдает ошибки NSException:
CCAction* action = [CCSequence actions:
[CCAnimate actionWithAnimation:[profile getAnimation:@"attack" index:currentDir]],
[CCCallFuncN actionWithTarget:self selector:@selector(shootBulletFrom:)],
nil];
NSInvalidArgumentException', reason: '-[Player shootBulletFrom:]: unrecognized selector sent to instance 0x703ec70'
редактировать:
Для получения дополнительной помощи и советов используйте метод shootBulletFrom в BulletCache.
Этот метод находится в BulletCache
-(void) shootBulletFrom:(CGPoint)startPosition velocity:(CGPoint)velocity frameName:(NSString*)frameName
isPlayerBullet:(bool)isPlayerBullet
{
CCArray* bullets = [batch children];
CCNode* node = [bullets objectAtIndex:nextInactiveBullet];
NSAssert([node isKindOfClass:[Bullet class]], @"not a Bullet!");
Bullet* bullet = (Bullet*)node;
[bullet shootBulletAt:startPosition velocity:velocity frameName:frameName
isPlayerBullet:isPlayerBullet];
nextInactiveBullet++;
if (nextInactiveBullet >= [bullets count])
{
nextInactiveBullet = 0;
}
}
Мне также рекомендовали изменить вызов [CCCallFuncN] внизу на:
[CCCallFuncN actionWithTarget:self selector:@selector(shootBulletFrom:shotPos velocity:velocity frameName:@"bullet1big.png" isPlayerBullet: YES)],
Но потом я получил ошибку компиляции: Expected ':' before Velocity