[Solved]Drawing primitives in c++

I am trying to draw primitives in cocos 2dx v3.6 but it seems that ccdrawlines is depreciated as well as trying to do

cocos2d::DrawPrimitives::drawLine(Vec2(0,150), Vec2(400,150));

Since it seems that these primitive drawing tools have been depreciated, how can I draw lines, polygons, etc…?

Look into DrawNode class.

The draw primitives have been replaced by the DrawNode class as pointed out by @smitpatel88. You can use the DrawNode by adding the following code to one of your init method of a Node:

auto drawnode = DrawNode::create();
drawnode->drawLine(Vec2(0,0), Vec2(500,500), Color4F(1.0, 0.0, 0.0, 1.0));
addChild(drawnode);

It is interesting to note that the width of the line is not customizable in DrawNode and is set to 1 regardless of the scale factor.

1 Like

Hi guys, than you all, DrawNode is exactly what I was looking for.