Following this: http://www.raywenderlich.com/4421/how-to-mask-a-sprite-with-cocos2d-1-0
And it works. However, for my needs I have to draw some cocos2d primitives in my sprite, and then, mask it.
So I made a subclass of CCSprite, and did this in the draw method:
-(void)draw {
[super draw];
glColor4f(1.0, 0.0, 0.0, 1.0);
glLineWidth(2.0);
ccDrawLine(ccp(0,0), ccp(480,320));
}
However, when I mask this sprite, the red line appears above everything (including the non-visible area).
I imagine I need a way to include my red line as part of the sprite's texture so that CCRenderTexture can properly take it all, but I'm not sure how.