Is the bug Z-Order bug fixed in RC0? (No, it isn't...)

Is the bug Z-Order bug fixed in RC0? (No, it isn't...)
0.0 0


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.

Does any one know if this is fixed in RC0?



I just tested it - and it is still a bug…

Took the standard HelloWorld generated project
Added LayerA class as follows;


#ifndef __LayerA_H_
#define __LayerA_H_
#include "cocos2d.h"

class LayerA: public cocos2d::Layer
	virtual bool init();
	virtual void draw(Renderer *renderer, const kmMat4& transform, bool transformUpdated);
#endif //__LayerA_H_


#include "LayerA.h"
bool LayerA::init()
	if ( !Layer::init() )
		return false;
	return true;
void LayerA::draw(Renderer* renderer, const kmMat4 &transform, bool transformUpdated)
	Node::draw(renderer, transform, transformUpdated);
	auto p0 = cocos2d::Point(0,0);
	auto p1 = cocos2d::Point(1000,1000);
	cocos2d::DrawPrimitives::drawLine(p0, p1);

Changed HelloorldScene/cpp as follows…

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

    // 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.

Anyone have a fix/work around?


Isn’t DrawPrimitives deprecated yet?

(I think) you should use DrawNode instead.


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!