Android Cocos2dx替换场景错误

Android Cocos2dx替换场景错误,android,c++,cocos2d-iphone,Android,C++,Cocos2d Iphone,场景我有主场景,我点击这个按钮我想打开另一个场景。但我得到了以下错误: 对“Oyemnu::scene()的未定义引用 主菜单 #ifndef MAINMENU_H_ #define MAINMENU_H_ #include "cocos2d.h" class MainMenu : public cocos2d::CCLayer { public: virtual bool init(); static cocos2d::CCScene* scene(); vi

场景我有主场景,我点击这个按钮我想打开另一个场景。但我得到了以下错误: 对“Oyemnu::scene()的未定义引用

主菜单

 #ifndef MAINMENU_H_
#define MAINMENU_H_

#include "cocos2d.h"

    class MainMenu : public cocos2d::CCLayer
    {
    public:
virtual bool init();


static cocos2d::CCScene* scene();
virtual void registerWithTouchDispatcher(void);
virtual void ccTouchesBegan(cocos2d::CCSet* touches, cocos2d::CCEvent* event);
virtual void ccTouchesMoved(cocos2d::CCSet* touches, cocos2d::CCEvent* event);
virtual void ccTouchesEnded(cocos2d::CCSet* touches, cocos2d::CCEvent* event);
virtual void ccTouchesCancelled(cocos2d::CCSet* touches, cocos2d::CCEvent* event);

void menuCloseCallback(CCObject* pSender);

CREATE_FUNC(MainMenu);


};


#endif 
MainMenu.cpp

#include "MainMenu.h"
#include "SimpleAudioEngine.h"
#include "Constants.h"
#include "OyunMenu.h"

#define COCOS2D_DEBUG 1

using namespace std;
USING_NS_CC;

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

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

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

// return the scene
return scene;
 }



bool MainMenu::init()
{
//////////////////////////////
// 1. super init first
if ( !CCLayer::init() )
{
    return false;
}   


this->setTouchEnabled(true);

CCSprite* oyuncuBul = CCSprite::create("oyuna-basla.png");
oyuncuBul->setPosition(ccp(150,260));
oyuncuBul->setTag(menuOyuncuBul);
this->addChild(oyuncuBul, 0); 
}

    void MainMenu::ccTouchesBegan(cocos2d::CCSet* touches, cocos2d::CCEvent* event)
    {
CCTouch *touch = (CCTouch*) (touches->anyObject());
CCPoint point = touch->getLocationInView();
point = CCDirector::sharedDirector()->convertToGL(point);

CCSprite *oyuncuBul=(CCSprite *)this->getChildByTag(menuOyuncuBul);

CCRect rectOyuncuBul = oyuncuBul->boundingBox();

if(rectOyuncuBul.containsPoint(point)){
    CCDirector::sharedDirector()->replaceScene(OyunMenu::scene());          
}
Oyemnu.h

#ifndef OYUNMENU_H_
#define OYUNMENU_H_

#include "cocos2d.h"

class OyunMenu : public cocos2d::CCLayer
{
 public:
virtual bool init();


static cocos2d::CCScene* scene();
virtual void registerWithTouchDispatcher(void);
virtual void ccTouchesBegan(cocos2d::CCSet* touches, cocos2d::CCEvent* event);
virtual void ccTouchesMoved(cocos2d::CCSet* touches, cocos2d::CCEvent* event);
virtual void ccTouchesEnded(cocos2d::CCSet* touches, cocos2d::CCEvent* event);
virtual void ccTouchesCancelled(cocos2d::CCSet* touches, cocos2d::CCEvent* event);

void menuCloseCallback(CCObject* pSender);

CREATE_FUNC(OyunMenu);


};


#endif 
Oyemnu.cpp

#include "OyunMenu.h"
#include "SimpleAudioEngine.h"
#include "Constants.h"

#define COCOS2D_DEBUG 1

using namespace std;
USING_NS_CC;

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

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

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

// return the scene
return scene;
}


// on "init" you need to initialize your instance
 bool OyunMenu::init()
{ 
//////////////////////////////
// 1. super init first
if ( !CCLayer::init() )
{
    return false;
}
}

您必须在jni文件夹的android.mk文件中添加这一行

../../Classes/oyemunu.cpp

#include "OyunMenu.h"
#include "SimpleAudioEngine.h"
#include "Constants.h"

#define COCOS2D_DEBUG 1

using namespace std;
USING_NS_CC;

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

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

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

// return the scene
return scene;
}


// on "init" you need to initialize your instance
 bool OyunMenu::init()
{ 
//////////////////////////////
// 1. super init first
if ( !CCLayer::init() )
{
    return false;
}
}
就像我被添加到我的android.mk文件中一样

本地_SRC_文件:=hellocpp/main.cpp\

               ../../Classes/Menu/AppDelegate.cpp\
               ../../Classes/Menu/HelloWorldScene.cpp\
               ../../Classes/Menu/MyScene.cpp\
               ../../Classes/Menu/LoadingLayer.cpp\
               ../../Classes/UI/NewLayer.cpp\
               ../../Classes/UI/HelpLayer.cpp
.h文件

CCSprite* oyuncuBul;
.cpp文件

oyuncuBul = CCSprite::create("oyuna-basla.png");
oyuncuBul->setPosition(ccp(150,260));
oyuncuBul->setTag(menuOyuncuBul);
this->addChild(oyuncuBul, 0); 





void MainMenu::ccTouchesBegan(cocos2d::CCSet* touches, cocos2d::CCEvent* event)
        {
    CCTouch *touch = (CCTouch*) (touches->anyObject());
    CCPoint point = touch->getLocationInView();
    point = CCDirector::sharedDirector()->convertToGL(point);



    CCRect rectOyuncuBul = oyuncuBul->boundingBox();

    if(rectOyuncuBul.containsPoint(point)){
        CCDirector::sharedDirector()->replaceScene(OyunMenu::scene());          
    }