我做了一个使用CCSprite和CCRenderTexture绘图的功能。喜欢
Paint *paintColor=Paint::create("texture1@2x.png");
draw=true;
CCPoint end = touch->getPreviousLocationInView();
end = CCDirector::sharedDirector()->convertToGL(end);
target->begin();
float distance = ccpDistance(start, end);
for (int i = 0; i < distance; i++)
{
paintColor->color=globalColor;
paintColor->setColor(paintColor->color);
paintColor->scale=globalScale;
paintColor->setScale(paintColor->scale);
paintColor->opacity=globalOpacity;
paintColor->setOpacity(paintColor->opacity);
float difx = end.x - start.x;
float dify = end.y - start.y;
float delta = (float)i / distance;
CCPoint p=ccp(start.x + (difx * delta), start.y + (dify * delta));
paintColor->originalPosition=p;
paintColor->setPosition(paintColor->originalPosition);
tempPath.path.push_back(p);
tempPath.color=globalColor;
tempPath.scale=globalScale;
tempPath.opacity=globalOpacity;
paintColor->visit();
}但我想要撤消功能,并想从CCRenderTexture中删除最后绘制纹理。任何人都可以帮助我实现这一功能。有什么方法可以从CCRenderTexture中删除精灵吗?
发布于 2015-07-17 19:51:45
在我的例子中,我确实喜欢关注。每当绘制完成(touchbegan,touchmove,touchend)时,我将RenderTexture图像保存在一个数组中。然后,当我单击undo按钮时,我从数组中提取图像并在RenderTexture上访问它。我希望它能对你有所帮助。
https://stackoverflow.com/questions/22145740
复制相似问题