2013-03-02 3 views
0

내 그림 기능에 paremter를 전달하려고 할 때마다 작동하지 않습니다.그리기 기능이 매개 변수와 함께 작동하지 않습니다.

- (void)drawxy:(CGPoint)startxy //doesnt work 
{ 
    glLineWidth(6.0f); 
    ccDrawLine(ccp(0, 0), ccp(150, 150)); 
} 
-(void)addEnemyAtX:(int)x y:(int)y dir:(int)direction 
{ 
    CCSprite *enemy = [CCSprite spriteWithFile:@"enemy1.png"]; 
    enemy.position = ccp(x, y); 
    enemy.rotation = [self findDirection:direction]; 
    [self addChild:enemy]; 
    [self drawxy:enemy.position]; 
    [enemies addObject:enemy]; 
} 

하지만 이렇게하면 어떤 이유로 선이 그려집니다. 내가 선 포인트의 결말에 enemy.position를 넣어 didnt가 알고

- (void)drawxy //works 
{ 
    glLineWidth(6.0f); 
    ccDrawLine(ccp(0, 0), ccp(150, 150)); 
} 
-(void)addEnemyAtX:(int)x y:(int)y dir:(int)direction 
{ 
    CCSprite *enemy = [CCSprite spriteWithFile:@"enemy1.png"]; 
    enemy.position = ccp(x, y); 
    enemy.rotation = [self findDirection:direction]; 
    [self addChild:enemy]; 
    [self drawxy]; 
    [enemies addObject:enemy]; 
} 

, 나는 단지 그것이 일부러하는 모든 일했다 있는지 확인하기 위해 테스트를했다. 도움을 많이 주셔서 감사합니다.

+0

은 내가 그리기 기능이 작동 대신 drawxy의 그릴의 이름을 변경할 때 – user2121776

답변

0
enemy.position=CGPointMake(cp.x, cp.y); 

그리고 어떤 이유로 호출 기능

[self drawxy:enemy.position]; 
관련 문제