Reputation: 416
I am creating Drawing app for ipad using cocos2d-iphone its using CCRenderTexture for drawing. I am able to take screenshot of my drawing and saving it to application document directory.
but now I want to load this as my background image to draw over it,and can change the image,so basically I want to merge my image with my render texture I tried this but image is appearing below my rendertexture (with z=-1), I am not able to figure it out. Is there any way to do this? Thanks
Upvotes: 0
Views: 772
Reputation: 416
so this is how i solved my problem
Step 1> created my RenderTexture
renderTexture = [[CCRendertexture alloc]initWithWidth:self.contentSize.width height:self.contentSize.height pixelFormat:kCCTexture2DPixelFormat_RGBA8888];
renderTexture.anchorPoint = ccp(0,0);
renderTexture.position = ccp(width*0.5,height*0.5f);
Step 2> Created CCSprite with background image
CCSprite *bgImage = [CCSprite spriteWithCGImage:myImage.CGImage key:imgkey];
bgImage.position = ccp(width*0.5f,height*o.5f);
Step3> This is important part in this
[renderTexture begin];
[bgImage visit];
[renderTexture end];
[self addChild:renderTexture]; // added to my layer as child
this tutorial helped me http://www.raywenderlich.com/4421/how-to-mask-a-sprite-with-cocos2d-1-0
I hope this will be helpful for someone
Upvotes: 1