2013-03-02 71 views
0

每當我嘗試將繪圖函數傳遞給繪圖函數時,它都不起作用。繪圖功能不能用於參數

- (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]; 
} 

但是,當我這樣做時,由於某種原因繪製一條線。

- (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]; 
} 

我知道我沒有把enemy.position進線點的結局,我只是測試,看看它是否曾在所有它沒有。 非常感謝您的幫助。

+0

由於某種原因,當我改變平局的功能名稱來繪製的,而不是drawxy它的工作原理 – user2121776 2013-03-02 05:25:59

回答

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

,並調用函數

[self drawxy:enemy.position];