午夜说再见 2016-03-18 16:32 采纳率: 0%
浏览 1317

刚开始学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”:找不到标识符

就是这样,请问该怎么解决呀?

  • 写回答

1条回答 默认 最新

  • 小呀小菜鸡 2016-06-06 09:13
    关注

    你在helloWord里面加载了secondscene的头文件吗

    评论

报告相同问题?

悬赏问题

  • ¥15 thinkphp6配合social login单点登录问题
  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch