Cocos2d x cocos2dx中关于Sprite::init()的错误

Cocos2d x cocos2dx中关于Sprite::init()的错误,cocos2d-x,Cocos2d X,我想创造一个游戏,像不要碰块。创建块时,我希望让Sprite可以初始化。代码如下: #pragma once #include<iostream> #include "cocos2d.h" #include "Block.h" USING_NS_CC; Block* CreateWithArgs(Color3B color, Size size, std::string label, float fo

我想创造一个游戏,像不要碰块。创建块时,我希望让Sprite可以初始化。代码如下:

        #pragma once
        #include<iostream>
        #include "cocos2d.h"
        #include "Block.h"
        USING_NS_CC; 

Block* CreateWithArgs(Color3B color, Size size, std::string label, float fontsize, Color4B textcolor)
{
    auto b = new Block();
    b->initWithArgs(color, size, label, fontsize, textcolor);
    b->autorelease();
    return b;

}


bool initWithArgs(Color3B color, Size size, std::string label, float fontsize, Color4B textcolor)
{

    Sprite::init();
    return true;
}
#pragma一次
#包括
#包括“cocos2d.h”
#包括“Block.h”
使用\u NS\u CC;
Block*CreateWithArgs(Color3B颜色、大小、标准::字符串标签、浮点fontsize、Color4B文本颜色)
{
自动b=新块();
b->initWithArgs(颜色、大小、标签、字体大小、文本颜色);
b->自动释放();
返回b;
}
bool initWithArgs(Color3B颜色、大小、标准::字符串标签、float fontsize、Color4B textcolor)
{
Sprite::init();
返回true;
}

但是当我编写此代码时,我发现了Sprite::init()中的错误;VS2012告诉我“无法访问受保护的成员(在cocos2d::Sprite类声明中)”

您正在编写C函数:

Block* CreateWithArgs(Color3B color, Size size, std::string label, float fontsize, Color4B textcolor)
bool initWithArgs(Color3B color, Size size, std::string label, float fontsize, Color4B textcolor)
在C++类方法中,需要用类的名称前缀,例如假设类是“代码> MySpReS</代码>:

Block* MySprite::CreateWithArgs(Color3B color, Size size, std::string label, float fontsize, Color4B textcolor)
bool MySprite::initWithArgs(Color3B color, Size size, std::string label, float fontsize, Color4B textcolor)