Skip to content

Instantly share code, notes, and snippets.

@sdabet
Created January 20, 2013 14:07
Show Gist options
  • Save sdabet/4578928 to your computer and use it in GitHub Desktop.
Save sdabet/4578928 to your computer and use it in GitHub Desktop.
@implementation NodeRenderer
+(id)renderTextureWithNode:(CCNode*)node width:(int)w height:(int)h
{
return [[[self alloc] initWithNode:node width:w height:h pixelFormat:kCCTexture2DPixelFormat_RGBA8888 depthStencilFormat:0] autorelease];
}
-(id) initWithNode:(CCNode*)n width:(int)w height:(int)h pixelFormat:(CCTexture2DPixelFormat)format depthStencilFormat:(GLuint)depthStencilFormat {
if(self = [super initWithWidth:w height:h pixelFormat:format]) {
[self addChild:n];
// Set blending function (for fading)
[self.sprite setBlendFunc:(ccBlendFunc){GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA}] ;
// Schedule update of the texture
[self schedule:@selector(renderChildren)];
[self renderChildren];
}
return self;
}
-(void) renderChildren {
[self begin];
for(int i=0; i<self.children.count; i++) {
[[self.children objectAtIndex:i] visit];
}
[self end];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment