I want to draw some customized opengl elements, like ccdrawline(). According to cocos2d documentation, I should override draw() method to draw my stuff in my subclassed layer. However it is not working. While if I override the visit() method, I can see what I want to draw. I am puzzled about this and I am seeking for ideas for solving this.
I made it like this:
- (void)draw
{
[super draw];
CGPoint a = ccp(0,0);
CGPoint b = ccp(480,320);
ccDrawLine(a,b);
}
Your code is correct and it should work. But I vaguely remember that draw isn’t called for CCLayer classes. Either way, draw or visit are virtually the same method, so just use whichever works.