I tried to find something for drawing rounded boxes and finished code from Rounded rect for DrawNode in Cocos2d-x · GitHub to quickly create nodes.
Features:
- At least, it works!
- Full color changes are supported (via
ActionsorsetColor/getColor). - Correct content size from start.
- If you want more advanced drawing, replace
myDrawfunction (don’t forget to set correct content size in yourinit!).
How to use:
#include "RoundedBox.hpp"
RoundedBox::create(Size(500, 500), 60.0f, false); // size, rounding radius, solid (optional, true by default).
Download (old): RoundedBox.zip (1.4 KB)
Dounload v2 (Replaced Vec2 with Size, some fixes): RoundedBox.zip (1.4 KB)