Hello,
We are trying to create paint app with Undo Redo functionality .
I am creating a renderTexture Like this.
this->canvas = CCRenderTexture::create(CCDirector::sharedDirector()->getWinSize().width-20, 550,kCCTexture2DPixelFormat_RGBA8888);
canvas->setPosition(ccp(winsize.width/2,winsize.height/2+44));
this->canvas->retain();
this->addChild(canvas,2);
And drawing everything on this renderTexture.
In CCTouchesEnded whatever i have drawn on renderTexture i am saving like this.
UndoMoveData *data = new UndoMoveData();
//creating New renderTextue.
CCRenderTexture *tex = CCRenderTexture::create(1100, 1396,kCCTexture2DPixelFormat_RGBA4444);
tex->setPosition(ccp(523,579));
tex->retain();
//Copying the canvas contents to new renderTexture
tex->begin();
canvas->visit();
tex->end();
data->lastTexture=tex;
//saving UndoMoveData in the array.
undoArray->addObject(data);
data->release();
OnClick Of Undo
//Retrieving the Undo Object
UndoMoveData *lastTexture= (UndoMoveData*)undoArray->lastObject();
//Copying the last texture contents to our main canvas
this->canvas->begin();
lastTexture->lastTexture->visit();
this->canvas->end();
Now the problem is after repeated undo redo, texture in the Canvas goes on stretching on some points (Please check the attached screenshots).
This problem appears on Cocos2dx 2.2.3 & even in Cocos2dx 3.1.1
However this problem doesn’t appear on cocos2d iPhone version.
ScreenShots