Redrawing screen in cocos2d
Is there a way to f开发者_开发问答orce a redraw in cocos2d? I have this code:
CGSize s = [CCDirector sharedDirector].winSize;
glLineWidth( 5.0f );
glEnable(GL_LINE_SMOOTH);
glColor4ub(255,0,0,255);
ccDrawLine( ccp(0, s.height), ccp(s.width, 0) );
which draws a red line. However it only works if I overload the draw method of a class. How can I get cocos2d or opengl to refresh?
What do you mean by refreshing? Is it like clearing the screen and drawing again? The draw function in open Gl es is called at every frame. I will explain.
Consider you want to draw line from p1 to p2. call ccDrawLine(p1,p2); in draw function. you can declare the points p1 and p2 global. Changing values of p1 and p2 will change the line accordingly. This is because the draw function is called and refreshed everytime a frame is drawn. the refresh rate = frame rate
精彩评论