Sorry t be lazy but it is late * I odn’t have a test program to hand.
There is a bug in the cocos2d v3 Beta that causes all openGl drawn primitives to be drawn behind all sprites - regarldess of the layer they are drawn from or the z-order of those layers.
Scene* HelloWorld::createScene()
{
// 'scene' is an autorelease object
auto scene = Scene::create();
// 'layer' is an autorelease object
auto layer = HelloWorld::create();
auto layerA = LayerA::create();
// add layer as a child to scene
scene->addChild(layerA);
scene->addChild(layer);
// return the scene
return scene;
}
Regardless of the order of the addChild method calls, the line drawn always appears Behind the sprite in the ‘layer’ layer.
I think the ‘work around’ aka the correct way to do it, is using the renderer->addCommand method so that the ‘primitive’ drawing is in the right place when the drawing actually takes place.
so, it’s not a ‘bug’ as such, it’s just that, if you draw directly during the draw() method, it gets drawn there and then, rather than being queued to be drawn like all the sprites.
Once you have your head around that, it all makes sense!