首页 > cocos2dx中新建的类在appdelegate中使用时报错

cocos2dx中新建的类在appdelegate中使用时报错

这个新建类的头文件

#pragma once
#include"cocos2d.h"
using namespace cocos2d;

class Background:public Layer
{
public:
    static cocos2d::Scene * creatScene();
    virtual bool init();

    CREATE_FUNC(Background);
};


这是新建类的cpp文件

#include "Background.h"
#include"cocos2d.h"
using namespace cocos2d;

Scene * Background::creatScene()
{
    auto scene = Scene::create();
    auto layer = Layer::create();
    scene->addChild(layer);
    return scene;
}

bool Background::init()
{
    return true;
}

然后我在appdelegate中加入头文件,在此处并没有报错

#include "Background.h"

将原来新建项目中的HelloWorld类换成我自己写的类后就报错了,说找不到这个类

auto scene = Background::creatScene();

上网找过资料,把类的包含目录给改了,所以在#include“Background.h”时并没有报错。
请问这种情况是什么原因,怎么办?

【热门文章】
【热门文章】