2

そこで、HelloWorld のシーンを「diffMenu」という難易度メニューのシーンに置き換えようとしています。XCode で問題なく動作するので、Android 側をテストするために Eclipse に移動しましたが、「`diffMenu::scene() への未定義参照」というエラーが表示されました。Android.mk に diffMenu.ccp を追加しましたが、まだ取得していますエラー。

Android.mk


LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := game_shared

LOCAL_MODULE_FILENAME := libgame

LOCAL_SRC_FILES := helloworld/main.cpp \
               ../../Classes/AppDelegate.cpp \
               ../../Classes/HelloWorldScene.cpp \
               ../../Classes/diffMenu.ccp

LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes                   

LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static cocosdenshion_static

include $(BUILD_SHARED_LIBRARY)

$(call import-module,CocosDenshion/android) $(call import-module,cocos2dx)







HelloWorldScene.ccp


#include "HelloWorldScene.h"
#include <sys/time.h>

#include "diffMenu.h"
USING_NS_CC; 


//using namespace CocosDenshion ;



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

    // 'layer' is an autorelease object
    HelloWorld *layer = HelloWorld::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 HelloWorld::init()
    {
        //////////////////////////////
        // 1. super init first
        if ( !CCLayer::init() )
        {
             return false;
        }




    CCSize size = CCDirector::sharedDirector()->getWinSize();
    CCSprite* background = CCSprite::create("menuBackground.jpg");
    //-------------------Background
    background->setPosition(ccp(170, 240));
    this->addChild(background, -1);

    //-------------------Green Play Now
    CCLabelTTF *playLabel = CCLabelTTF::create("Play Now", "American Typewriter", 40.0);
    CCMenuItemLabel *playNow = CCMenuItemLabel::create(playLabel, this,     menu_selector(HelloWorld::play));
    playNow->setPosition(ccp(0, 50));
    playNow->setColor(ccc3(0, 255, 0));


    //-------------------White Difficulty
    CCLabelTTF *diffLabel = CCLabelTTF::create("Difficulty", "American Typewriter", 40.0);
    CCMenuItemLabel *difficulty = CCMenuItemLabel::create(diffLabel, this,     menu_selector(HelloWorld::diff));
    difficulty->setPosition(ccp(0, -25));
     difficulty->setColor(ccc3(255, 255, 255));

    //-------------------White Language
    CCLabelTTF *langLabel = CCLabelTTF::create("Language", "American Typewriter", 40.0);
    CCMenuItemLabel *language = CCMenuItemLabel::create(langLabel, this,     menu_selector(HelloWorld::lang));
    language->setPosition(ccp(0, -100));
    language->setColor(ccc3(255, 0, 0));

    //-------------------Red Credits
    CCLabelTTF *credLabel = CCLabelTTF::create("Credits", "American Typewriter", 40.0);
    CCMenuItemLabel *credits = CCMenuItemLabel::create(credLabel, this,      menu_selector(HelloWorld::cred));
    credits->setPosition(ccp(0, -175));
    credits->setColor(ccc3(0, 0, 0));

    //-------------------Add Menu
    CCMenu *menu = CCMenu::create(playNow,difficulty,language,credits, NULL);
    this->addChild(menu,2) ;

    return true;
}
void HelloWorld::diff()
{




    CCDirector::sharedDirector()->setDepthTest(true);


    CCDirector::sharedDirector()->replaceScene(CCTransitionPageTurn::create(1.0f,       diffMenu::scene(), false));

}

void HelloWorld::play(){


}
void HelloWorld::cred(){


}

void HelloWorld::lang(){


}
void HelloWorld::menuCloseCallback(CCObject* pSender)
{
    CCDirector::sharedDirector()->end();

#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
    exit(0);
    #endif
}






diffMenu.h

#ifndef __diffMenu_SCENE_H__
#define __diffMenu_SCENE_H__

#include "cocos2d.h"
USING_NS_CC ;
class diffMenu : public cocos2d::CCLayer
{
public:
    // Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning      'id' in cocos2d-iphone
    virtual bool init();  

    // there's no 'id' in cpp, so we recommand to return the exactly class pointer
    static cocos2d::CCScene* scene();

    // a selector callback
    //void menuCloseCallback(CCObject* pSender);

    // implement the "static node()" method manually
    LAYER_CREATE_FUNC(diffMenu);


    void play();
    void diff();




};


#endif // __diffMenu_SCENE_H__



diffMenu.ccp

#include "SimpleAudioEngine.h"
#include "diffMenu.h"
using namespace cocos2d;
using namespace CocosDenshion;

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

    // 'layer' is an autorelease object
    diffMenu *layer = diffMenu::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 diffMenu::init()
{
//////////////////////////////
// 1. super init first
if ( !CCLayer::init() )
{
    return false;
}

/////////////////////////////
// 2. add a menu item with "X" image, which is clicked to quit the program
//    you may modify it.

// add a "close" icon to exit the progress. it's an autorelease object

    /////////////////////////////
    // 3. add your codes below...

    // add a label shows "Hello World"
    // create and initialize a label
    CCLabelTTF* pLabel = CCLabelTTF::create("Hello World", "Thonburi", 34);

    // ask director the window size
    CCSize size = CCDirector::sharedDirector()->getWinSize();

    // position the label on the center of the screen
    pLabel->setPosition( ccp(size.width / 2, size.height - 20) );

    // add the label as a child to this layer
    this->addChild(pLabel, 1);

    // add "diffMenu" splash screen"
    CCSprite* pSprite = CCSprite::create("pencilBackground.jpg");
    pSprite->setScale(.7);
    pSprite->setRotation(-1);
    // position the sprite on the center of the screen
    pSprite->setPosition( ccp(size.width/2-80, size.height/2) );

    // add the sprite as a child to this layer
    this->addChild(pSprite, 0);

    return true;
}

/*void diffMenu::menuCloseCallback(CCObject* pSender)
{
    CCDirector::sharedDirector()->end();

#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
    exit(0);
#endif
}*/
4

1 に答える 1

1

最後にスペルミスです。そのはず

diffMenu.cpp

いいえ

diffMenu.ccp

Android.mk で

于 2012-08-29T02:29:03.553 に答える