为什么我不能覆盖 cocos2d::sprite 的绘制方法?

Why Can't I override draw method from cocos2d::sprite?

我需要重写 sprite 的绘图方法以应用一些自定义内容,但它根本没有影响我的绘图重写。我很确定我做对了:

.h 文件:

virtual void draw(cocos2d::Renderer* renderer, const cocos2d::Mat4& transform, bool transformUpdated);

.cpp 文件:

void CustomSprite::draw(cocos2d::Renderer* renderer, const cocos2d::Mat4& transform, bool transformUpdated)
{
    int x = 0;   //breakpoint here
}

我的 class 是

#include "cocos2d.h"

class CustomSprite : public cocos2d::Sprite
{

解决方案是:

in .h:
virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, uint32_t flags) override;

in .cpp:
void EnergyManager::draw(cocos2d::Renderer* renderer, const cocos2d::Mat4& transform, uint32_t flags)

感谢 Kobyle