내 코드에는 두 개의 글 머리 기호 관련 클래스가 있습니다. 글 머리 기호 및 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)],
그러나 나는 컴파일 오류가 발생했습니다 : 예상 ' : 'before Velocity
이 코드는 모두 싱글 톤 패턴을 사용하는 것처럼 보입니다. 싱글 톤 패턴을 사용하기는하지만, 내가 글 머리 기호를 얻은 곳이기는하지만, 내가 바꾸려고하는 것입니다. 글 머리 기호 코드를 포팅 한 프로젝트는 사운드 엔진을 제외하고는 싱글 톤 패턴을 사용하지 않습니다. – GPP