【问题标题】:Why am I getting a "use of undeclared identifier error"?为什么我会收到“使用未声明的标识符错误”?
【发布时间】:2014-08-04 12:06:44
【问题描述】:

错误行是:

test = Grid::createGrid("empty.png");

声明类的源文件是:

Grid* Grid::createGrid(std::string texture)
{
    Grid* pGrid = new Grid();
    pGrid->initWithFile(texture);
    pGrid->autorelease();
    Size size = Director::getInstance()->getVisibleSize();
    int scale = pGrid->getContentSize().height/((size.height-size.height*0.1)/10);
    pGrid->setScale(scale, scale);

    return pGrid;
}

我确信这应该可以工作,因为我在 xcode 中也为另一个程序完成了完全相同的代码...

【问题讨论】:

  • 看起来test 没有声明?
  • test =Grid*前面扔一个auto

标签: xcode cocos2d-x cocos2d-x-3.0


【解决方案1】:

应该有一个测试声明,例如:

Grid* test;

或者:

Grid* test = Grid::createGrid("empty.png");

或者:

@property Grid* test;

【讨论】:

    猜你喜欢
    • 2021-03-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-07
    • 2013-04-22
    相关资源
    最近更新 更多