cocos2dx DrawNode和ClippingRectangleNode 使用详解
来源:互联网 发布:淘宝短网址生成 编辑:程序博客网 时间:2024/05/20 09:09
cocos2dx DrawNode和ClippingRectangleNode 使用详解 auto s = Director::getInstance()->getWinSize(); auto layer = LayerGradient::create(Color4B(0,255,0,255), Color4B(255,255,0,255)); layer->setIgnoreAnchorPointForPosition(false); layer->setPosition(Vec2(s.width/2, s.height/2)); this->addChild(layer); auto draw = DrawNode::create(); addChild(draw, 20); draw->setLineWidth(20); draw->drawLine(Vec2(0,s.height/2.0), Vec2(s.width/2.0, s.height/2.0), Color4F(1.0, 1.0, 1.0, 1.0)); auto moveby = MoveBy::create(0.0, Vec2(-s.width/4.0, 0)); draw->runAction(moveby); moveby = MoveBy::create(4.0, Vec2(s.width/4.0, 0)); draw->runAction(moveby); { auto draw1 = DrawNode::create(); addChild(draw1, 20); draw1->setLineWidth(20); draw1->drawLine(Vec2(s.width/2.0,s.height), Vec2(s.width, s.height), Color4F(1.0, 1.0, 1.0, 1.0)); auto moveby = MoveBy::create(4.0, Vec2(0, -s.height/2.0)); draw1->runAction(moveby); } { auto clipper = ClippingRectangleNode::create(); clipper->setClippingRegion(Rect( -s.width/4.0, -s.height/2.0, s.width/2.0, s.height));//模板大小 this->addChild(clipper); clipper->setAnchorPoint( Vec2(0.5, 0.5) ); clipper->setPosition(Vec2(s.width/2.0 + s.width/4.0, s.height/2.0 + s.height/2.0)); auto content = Sprite::create(s_back2); content->setAnchorPoint( Vec2(0.5, 0.5) ); content->setPosition(0.0, 0.0); clipper->addChild(content);//底板 auto moveby = MoveBy::create(5.0, Vec2(0, -s.height/2.0)); clipper->runAction(moveby); } { auto clipper = ClippingRectangleNode::create(); clipper->setClippingRegion(Rect( -s.width/4.0, -s.height/4.0, s.width/2.0, s.height/2.0));//模板大小 this->addChild(clipper); clipper->setAnchorPoint( Vec2(0.5, 0.5) ); clipper->setPosition(Vec2(s.width/2.0 - s.width/4.0, s.height/2.0 + s.height/4.0)); auto content = Sprite::create(s_back2); content->setAnchorPoint( Vec2(0.5, 0.5) ); content->setPosition(0.0, 0.0); clipper->addChild(content);//底板 auto moveby = MoveBy::create(2.0, Vec2(0, -s.height/4.0)); clipper->runAction(moveby); auto delay = DelayTime::create(2.0); moveby = MoveBy::create(5.0, Vec2(s.width/4.0, 0)); content->runAction(Sequence::create(delay, moveby, NULL)); }
阅读全文
0 0
- cocos2dx DrawNode和ClippingRectangleNode 使用详解
- cocos2dx-js cc.DrawNode
- cocos2dx中DrawNode画线锯齿和非凸多边形填充
- cocos2dx-3.2(34) DrawNode 绘图API
- cocos2dx给DrawNode的shader传递Texture2D
- DrawNode
- cocos2dx3.0 DrawNode的使用
- 【DrawNode比较先进】cocos2dx3.0 DrawNode的使用
- cocos2dx[3.2](17)——简单绘图DrawNode
- cocos2dx DrawNode.drawSegment绘制出来的线粗细不一
- Cocos2d-x3.1中DrawNode的使用
- cocos2d-x 3.x DrawNode的使用
- Cocos2d-x绘图API:DrawingPrimitives和DrawNode
- cocos2dx使用lua和protobuf
- cocos2dx使用lua和protobuf
- cocos2dx libevent简介和使用
- cocos2dx libevent简介和使用
- cocos2dx使用lua和protobuf
- 6.常用java操作
- pkg-config用法详解
- mysql启动
- C#获取系统文件、文件夹和磁盘驱动器图标
- Android界面编程之实现改变图片透明度并提供细节查看
- cocos2dx DrawNode和ClippingRectangleNode 使用详解
- 利用Sobel算子,求梯度图像
- Codewars解题Playing with digits
- GitHub Branch / SSH clone URL / Clone in Desktop / Download ZIP
- jzoj P2249 蒸发学水
- 访问wamp的localhost出现“没有权限访问”解决方法
- ubuntu14.04小技巧
- 直方图均衡化(Histogram equalization)与直方图规定化
- 小程序app.json文件浅析