Draw Override nightmare

it is very frustrating… I’ve trying for few days now to override draw in my class that inherits from Sprite to draw an rectangle

void EnergyManager::draw(cocos2d::Renderer* renderer, const cocos2d::Mat4& transform, uint32_t flags)

and I am using those methods to draw: ccDrawSolidRect, ccDrawColor4F, glLineWidth, ccDrawRect

it draws perfectly… the issue is it ALWAYS renders behind any sprite regardless the order I addChild or set the zorder

The same approach works great in regular iphone cocos2d…

anyone could throw any tip please…

See the thread
http://discuss.cocos2d-x.org/t/can-no-longer-override-draw-function/12303

That might help.

Essentially, you no linger override draw and draw to the screen immediately, because all other drawing is queued up - so you need to add your drawing to the queue too.

“Drawing” now adds commands to the render queue. If you draw immediately, which you can still do, then when the render queue gets around to being drawn, it will draw over all immediate stuff.

Take a look at DrawNode and use that instead for lines etc.