1.helloworldscene.h
Cocos2d::D rawnode* _eraser;cocos2d::rendertexture*_rendertexture;
In the Init method of 2.helloworldscene.cpp
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,Ten, 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. Touch Move callback function
VEC2 pos=touch->getlocation (); // Mouse Position _eraser-SetPosition (POS); Blendfunc Blendfunc={gl_one,gl_zero};_eraser-setblendfunc (blendfunc); _rendertexture- >begin (); _eraser-visit (); _rendertexture->end ();
Cocos2d-x 3.x eraser function