Closed NgVThangBz closed 5 months ago
Im working on a 'new' DrawNode class (currently available as extension DrawNodeEx). I have seen this "wrong" behavior too. This feature will be on a "next" version.
Workaround: Create an own DrawNode object for each "drawing primitives".
Workaround: Create an own DrawNode object for each "drawing primitives".
Yes, that's a temporary solution, or can convert line and point into polygons.
Workaround: Create an own DrawNode object for each "drawing primitives".
Yes, that's a temporary solution, or can convert line and point into polygons.
Thats not so easy as you think. There a lot of different scenarios for correct drawing order. @halx99 Please add tag: 'need founding' and anything like: 'workaround exist' and/or 'helpdesk' only
Add a method to set the correct draw order :
drawNode->drawLine(Vec2(20, 20), Vec2(200, 200), Color4B::RED);
drawNode->drawSolidRect(Vec2(50, 50), Vec2(150, 150), Color4B::YELLOW);
drawNode->drawLine(Vec2(30, 20), Vec2(210, 200), Color4B::BLUE);
merged/solved with #1914 @NgVThangBz please close it.
Looking at the code below, you can see that in the draw node the drawing order will be triangle, point, line: So even if the triangle is added after the point, it is still drawn first, leading to the triangles always being covered by lines,
In my opinion: it would be good if lines, triangles, points are drawn one after another in the order they are added
can check code:
DrawNode* _drawNode = DrawNode::create();
Director::getInstance()->getRunningScene()->addChild(_drawNode,100);
_drawNode->drawLine(Vec2(200,200),Vec2(500,500),Color4B::RED);
_drawNode->drawSolidRect(Vec2(200,200),Vec2(500,500),Color4B::YELLOW);
and result: