The GameScene.cpp source file code is as follows:
auto gameoverScene = GameOverScene::create();
gameoverScene->setScore(_score);
Director::getInstance()->replaceScene(TransitionFade::create(1.0f, gameoverScene));
But this line shows an error:
gameoverScene->setScore(_score);
The error is as follows:
1>E:\cocos2d-x-3.17\tests\game3\Classes\GameScene.cpp(130,24): error C2039: “setScore”: not a member of “GameOverScene”
1>E:\cocos2d-x-3.17\tests\game3\Classes\GameOverScene.h(9): message : See declaration of “GameOverScene”
I have declared the setScore function in GameOverScene.h. And the setScore function is defined in the GameOverScene.cpp file. Why is it still showing an error saying “setScore”: is not a member of “GameOverScene”?
The code in the GameOverScene.h file is as follows:
void setScore(int score);
The code in the GameOverScene.CPP file is as follows:
void GameOverScene::setScore(int score)
{
_score = score;
}