RoundedBox: helper class to create solid rounded boxes

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! :smile:
  • Full color changes are supported (via Actions or setColor/getColor).
  • Correct content size from start.
  • If you want more advanced drawing, replace myDraw function (don’t forget to set correct content size in your init!).

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)

1 Like