Hi, sorry to bother you again with what appears to be a noob question but I can’t seem to be able to solve the problem. So, I’m trying to subclass the layer class and subclass that class as well.
class Main:Layer and then Game:Main
The problem that I have is an error with the virtual init() function that looks something like this: error LNK2019: unresolved external symbol “public: virtual bool __thiscall Main::init(void)” (?init@Main@@UAE_NXZ) referenced in function “public: virtual bool __thiscall Game::init(void)” (?init@Game@@UAE_NXZ)
The source code looks like this:
Main.h
include "cocos2d.h"
class Main : public cocos2d::Layer
{
public:
virtual bool init();
};
Main.cpp:
include "Main.h"
USING_NS_CC;
bool Main::init()
{
if ( !Layer::init() )
{
return false;
}
CCLOG("Main::init");
return true;
}
Game.h
include "Main.h"
class Game : public Main
{
public:
static cocos2d::Scene* createScene();
virtual bool init();
void onEnterTransitionDidFinish();
void onEnter();
CREATE_FUNC(Game);
}
Game.cpp
include "Game.h"
USING_NS_CC;
Scene* Game::createScene()
{
auto scene = Scene::create();
auto layer = Game::create();
scene->addChild(layer);
return scene;
}
bool Game::init()
{
if ( !Main::init() )
{
return false;
}
CCLOG("Game::init");
return true;
}
// and the implementation of the other functions goes here...
So what am I doing wrong?