Cocos2d-x v3 Cannot override forward function Draw

北战南征 提交于 2019-12-06 10:05:00

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/23557033/cocos2d-x-v3-cannot-override-forward-function-draw

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!