码迷,mamicode.com
首页 > 其他好文 > 详细

cocos2d-x 3.x 橡皮擦功能

时间:2016-06-08 17:12:12      阅读:236      评论:0      收藏:0      [点我收藏+]

标签:

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 橡皮擦功能

标签:

原文地址:http://www.cnblogs.com/kingBook/p/5570640.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!