0
私のコードには、2つのBullet関連のクラスがあります。 BulletとBulletCache。 BulletCacheは一定の数の弾丸を作る-Cocos2d
を作成します私は、弾丸を撃つための新しい弾丸作成メソッドを作成するだけです。私はCCFuncNメソッドを使用しますが、ゲームは現在、NSExceptionエラーを投げている。ここでさらにヘルプとアドバイスについて
BulletCacheでshootBulletFrom方法である:
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
-(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)],
しかし、私は、コンパイルエラーを得た:期待します " : 'Velocityの前に
これらのコードはいずれもシングルトンパターンを使用しているようですが、シングルトンパターンを使用していますが、ここではコードを取得していますが、変更しようとしています。弾丸コードを移植したプロジェクトは、サウンドエンジン以外のシングルトンパターンを使用しません。 – GPP