Search code examples
imagecocos2d-iphoneccsprite

CCSprite save the effect so that next action to be performed on changed CCSprite in xcode for iphone


I have performed CCLens3D effect on CCsprite after action i have to save CCSprite to png. Please help me I have used following code

@implementation HelloWorldLayer

CCSprite *img;

-(void)lensEffect:(CGPoint )touchpoint
{
    const CGSize size = [[CCDirector sharedDirector] winSize];
    NSLog(@"%f",touchpoint.x);

   // const CGSize size = [[CCDirector sharedDirector] winSize];
    id lens = [CCLens3D actionWithPosition:CGPointMake(touchpoint.x,touchpoint.y)
                                    radius:50.f
                                      grid:ccg(20.f,20.f)
                                  duration:0.f];
    [img runAction:lens];
}

After [img runAction:lens] I have to save img with action?


I have got the screen shot but after performing two three time lens effect the image is seems to be blur please help if u now hoe to keep resolution of image same after lens effect.

thks in advance


Solution

  • You need to use a CCRenderTexture. Set it up as described here (screenshot part) and then call [img visit] to render the sprite onto the render texture.