Why the CCLayer can't use a for loop in draw method??

Posted by Tattat on Stack Overflow See other posts from Stack Overflow or by Tattat
Published on 2010-04-22T11:30:28Z Indexed on 2010/04/22 11:33 UTC
Read the original article Hit count: 496

Filed under:
|
|
|

I have a CClayer, that have a draw method, every second, it will call the draw method 60 times. So, I have method like this:

-(void)draw{
    glEnable(GL_LINE_SMOOTH); 
    glColor4f(0.0f, 1.0f, 0.0f, 1.0f);
    glLineWidth(5.0f);
    ccDrawLine(ccp(300,20), CGPointZero);

}

I work great. but after I added a for looop, for example....:

-(void)draw{
    glEnable(GL_LINE_SMOOTH); 
    glColor4f(0.0f, 1.0f, 0.0f, 1.0f);
    glLineWidth(5.0f);
    ccDrawLine(ccp(300,20), CGPointZero);
    for(int i=0; i<5; i++){
   NSLog(@"Testing the loop, %i", i);
    }

}

It can't draw anything, the screen only black. But I can see the Testing the loop is keep calling.... Why? thank you.

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about cocos2d