cocos2d-x 3.x 橡皮擦功能

1.HelloWorldScene.h

cocos2d::DrawNode* _eraser;
cocos2d::RenderTexture*_renderTexture;

2.HelloWorldScene.cpp 的init方法中

Size visibleSize = Director::getInstance()->getVisibleSize();
Vec2 center=Vec2(visibleSize.width*0.5f+origin.x,visibleSize.height*0.5f+origin.y);
_eraser=DrawNode::create();
_eraser->drawDot(Vec2::ZERO,,Color4F(,,,));
_eraser->retain(); _renderTexture=RenderTexture::create((int)visibleSize.width,(int)visibleSize.height);
_renderTexture->setPosition(center);
addChild(_renderTexture); Sprite*spirte=Sprite::create("title_bg.jpg");
spirte->setAnchorPoint(Vec2(0.5f,0.5f));
spirte->setPosition(center);
spirte->retain(); _renderTexture->begin();
spirte->visit();
_renderTexture->end();

3.触摸移动回调函数

Vec2 pos=touch->getLocation();//鼠标位置

_eraser->setPosition(pos);

BlendFunc blendFunc={GL_ONE,GL_ZERO};
_eraser->setBlendFunc(blendFunc); _renderTexture->begin();
_eraser->visit();
_renderTexture->end();
上一篇:mysql 清空表——truncate 与delete的区别


下一篇:解决:HttpClient导致应用出现过多Close_Wait的问题