问题描述
- 刚开始学cocos2dx,编译错误,求助大神~
-
我新建了一个场景类SecondScene//SecondScene.h
#ifndef SecondScene_H
#define SecondScene_H
#include "cocos2d.h"
#include "HelloWorldScene.h"
using namespace cocos2d;class SecondScene :public CCLayer {
public:
static CCScene* scene();
virtual bool init();
CREATE_FUNC(SecondScene);
};
#endif//SecondScene.cpp
#include "SecondScene.h"
CCScene* SecondScene::scene()
{
CCScene* scene = CCScene::create();
SecondScene* layer = SecondScene::create();
scene->addChild(layer);
return scene;
}
bool SecondScene::init()
{
CCLabelTTF* label = CCLabelTTF::create("Hahaha", "Arial", 40);
label->setPosition(ccp(200, 200));
this->addChild(label);
return true;
}然后在HelloWorldScene.cpp的回调函数里用到:
void HelloWorld::menuCloseCallback(Ref* pSender)
{
//Director::getInstance()->end();
CCDirector::sharedDirector()->replaceScene(SecondScene::scene());
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
exit(0);
#endif
}可是编译出了错误,提示我:
“SecondScene”:不是类活命名空间的名称
“scene”:找不到标识符就是这样,请问该怎么解决呀?