问题
//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