Created
January 20, 2013 14:07
-
-
Save sdabet/4578928 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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