由于预编译文件重复,导致下面的类没有被编译,所以,在写代码的时候也没有提示还报错,说LoadingScene没有定义。
#ifndef __HELLOWORLD_SCENE_H__
#define __HELLOWORLD_SCENE_H__
#include "cocos2d.h"
class HelloWorld : public cocos2d::Layer
{
public:
static cocos2d::Scene* createScene();
virtual bool init();
// a selector callback
void menuCloseCallback(cocos2d::Ref* pSender);
// implement the "static create()" method manually
CREATE_FUNC(HelloWorld);
};
#endif // __HELLOWORLD_SCENE_H__
#ifndef __HELLOWORLD_SCENE_H__
#define __HELLOWORLD_SCENE_H__
#include "cocos2d.h"
class LoadingScene : public cocos2d::Layer
{
public:
// there's no 'id' in cpp, so we recommend returning the class instance pointer
static cocos2d::Scene* createScene();
// Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone
virtual bool init();
// implement the "static create()" method manually
CREATE_FUNC(LoadingScene);
virtual void onEnter() override;
virtual void onExit() override;
private:
float progressPercent = 0.0f;
float everyAdd = 5.0f;
cocos2d::ProgressTimer *loadProgress = nullptr;
cocos2d::LabelTTF* loadLabel;
cocos2d::LabelTTF* percentLabel;
void preloadResource();
void progessAdd();
void loadingCallback (cocos2d::Texture2D*);
};
#endif // __LoadingScene_SCENE_H__