lua的写法
local myDrawNode=cc.DrawNode:create() self:addChild(myDrawNode,10) myDrawNode:setPosition(cc.p(480,320)) myDrawNode:drawSolidRect(cc.p(100,100),cc.p(20,20),cc.c4f(1,1,1))
c++的写法
DrawNode*myDraw=DrawNode::create(); this->addChild(myDraw,10); myDraw->drawLine(Vec2(0,0),Vec2(480,320),Color4F(1,1)); myDraw->drawRect(Vec2(23,23),Vec2(500,500),1)); myDraw->setPosition(Vec2(90,90)); //myDraw->setScale(0.2); myDraw->drawSolidCircle(Vec2(100,50,CC_DEGREES_TO_RADIANS(90),1)); //myDraw->drawSolidCircle( VisibleRect::center() + Vec2(140,40,2.0f,Color4F(0.0,1.0,0.0,1.0));原文链接:https://www.f2er.com/cocos2dx/343137.html