2012-01-02 9 views
0

내 코드에는 두 개의 글 머리 기호 관련 클래스가 있습니다. 글 머리 기호 및 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

답변

1

당신은 shootBulletFrom에 대한 코드를 언급하지 않았으며 오류는 동일한 오류가 있음을 나타냅니다. .h 파일이나 다른 함수로 함수를 선언하지 않았을 수 있습니다. 그래서 가능한 경우 언급하십시오.

thisthis 링크로 이동할 수 있습니다. 그들은 총알을 발사하는 응용 프로그램에 대한 좋은 예를 들고 있습니다. 희망은 당신을 도와줍니다.

+0

이 코드는 모두 싱글 톤 패턴을 사용하는 것처럼 보입니다. 싱글 톤 패턴을 사용하기는하지만, 내가 글 머리 기호를 얻은 곳이기는하지만, 내가 바꾸려고하는 것입니다. 글 머리 기호 코드를 포팅 한 프로젝트는 사운드 엔진을 제외하고는 싱글 톤 패턴을 사용하지 않습니다. – GPP

관련 문제