Search code examples
xcodecocos2d-xcocos2d-x-3.0

Why am I getting a "use of undeclared identifier error"?


The error line is:

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

the source file declaring the class is:

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;
}

I am sure this should work as I have done the exact same code for another program also in xcode...


Solution

  • There should be a declaration for the test, like:

    Grid* test;
    

    Or:

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

    Or:

    @property Grid* test;