ccDrawRect does nothing

Sorry for the rookie question! But for some reason I am not able to draw a rectangle with:

ccDrawRect(CCPointMake(100, 100), CCPointMake(200, 200));

Nothing appears on the screen. I have tried white as well as black background for the layer. Am I missing something? Does using ccDrawRect requires some pre-setup? like setting linewidth or drawing color?

Please help.

Thanks.

Pritam.

Ok Figured it out. Actually the ccDrawXXX functions only work in the draw method of the layer! I was trying to it in init method of the layer.

So to get this working you need to add a

void draw();

function to your .h file for the layer and in the .cpp file do something like this:

void GameLayer::draw()
{
CCLayerColor::draw();
ccDrawColor4B(0, 0, 0, 255);
ccDrawRect(ccp(100,100), ccp(200,200));
}

Hope it helps someone!

Thanks.

Pritam.