Question

//in my .h file
virtual void draw();

//in .cpp
void GameLayer:draw()
{
   Layer::draw();
   //draw code goes here
}

It shows cannot override forward function node::draw()

As far as I know, it was working on the old versions. Is there any new approach in cocos2d-x 3.0?

Thanks in advance.

Was it helpful?

Solution

in v3.0 overriding the draw() method has changed.

try in .h:

virtual void draw(Renderer* renderer, const kmMat4& transform, bool transformUpdated);

try in cpp:

void draw(Renderer* renderer, const kmMat4& transform, bool transformUpdated)
{

}

If you are running the latest version 3.1 from GitHub, this has changed. Replace kmMat4 with Matrix

Edit: maybe you need to namespace it: cocos2d::Renderer

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top