私のコードには Bullet 関連のクラスが 2 つあります。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'
編集:
さらにヘルプとアドバイスが必要な場合は、BulletCache の shotBulletFrom メソッドを参照してください。
このメソッドは 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)],
しかし、その後、コンパイルエラーが発生しました: 速度の前に ':' が必要です