cocos2d-x 3.x 橡皮擦功能
Posted kingBook
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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,10,Color4F(0,0,0,0)); _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();
以上是关于cocos2d-x 3.x 橡皮擦功能的主要内容,如果未能解决你的问题,请参考以下文章