There are times where instead of overriding the "draw" method, you need to create a sprite that is a solid rectangle. There are a few ways to do it, but the easiest for me is to create a 1x1px PNG file. The color can be changed during runtime as needed.
Reference: http://stackoverflow.com/questions/3339955/cocos2d-solid-color-rectangular-sprite
create a blank Sprite, then set TextureRect and Color.
ReplyDelete(no need any png file).
auto *sprite = Sprite::create();
sprite->setTextureRect(Rect(0, 0, width, height));
sprite->setColor(color);