Projects > cpp > Issues > Bug #4364

We are migrating issue tracker of Cocos2d-x Project to Github, please create new issue there. Thanks.

Create Issue on Github

"MainScene::MainScene()", referenced from:

Bug #4364 [Closed]
dinesh_kachhot 2014-03-12 05:42 . Updated over 10 years ago

I am using cocos2d-x 2.2.2 in xcode 5 .

My problem is when i add new c++ class same as HelloWorldScene.cpp .

But when i run it is giving this error

Apple Mech-o Linker Error
"MainScene::MainScene()", referenced from:

This is my MainScene.h File Code

#ifndef __SpaceShooter__MainScene__
#define __SpaceShooter__MainScene__

#include "cocos2d.h"

class MainScene : public cocos2d::CCLayer{
public:
    MainScene();
    bool init();
    static cocos2d::CCScene* scene();

CREATE_FUNC(MainScene);
};

#endif /* defined(__SpaceShooter__MainScene__) */

And this is my MainScene.cpp file Code

#include "MainScene.h"

USING_NS_CC;

CCScene* MainScene::scene()
{
    // 'scene' is an autorelease object
    CCScene *scene = CCScene::create();

    // 'layer' is an autorelease object
    MainScene *layer = MainScene::create();

    // add layer as a child to scene
    scene->addChild(layer);

    // return the scene
    return scene;
}

bool MainScene::init(){

    return true;
}

Please Help me to get out of here.....

dabingnn 2014-03-12 06:43
  1. The reason of the link error is that you have not implemented MainScene constructor function. You just declared in header file.
  2. Please send a forum post first, this is not an issue of cocos2d. A post in forum is better. Thank you.
walzer@cocos2d-x.org 2014-10-08 02:49

Redmine issue system is closed, we are using github issue system instead.

This issue was moved to https://github.com/cocos2d/cocos2d-x/issues/8358

Atom PDF

Status:Closed
Start date:2014-03-12
Priority:Low
Due date:
Assignee:-
% Done:

0%

Category:android, ios, wp8
Target version:-