把cocos2dx 2.2的项目移植到 cocos2dx 3.8

来源:互联网 发布:英汉翻译软件语音 编辑:程序博客网 时间:2024/06/05 00:19

原因:要送个消消乐游戏给人,有个现成的cocos2dx 2.2项目,但搭建cocos2dx 2.2版本的安卓编译环境各种失败,于是就想升级到3.8,方便编译安卓apk包。


归纳变化如下

1 CC开头的类名,如果找不到,去掉CC


2 触摸事件变更。

覆盖ccTouchBegan,ccTouchMoved, ccTouchEnded,ccTouchCancelled触摸函数修改为事件监听

        EventListenerTouchOneByOne *touchListener = EventListenerTouchOneByOne::create();
touchListener->onTouchBegan = CC_CALLBACK_2(GameLayer::ccTouchBeganCallback, this);
touchListener->onTouchMoved = CC_CALLBACK_2(GameLayer::ccTouchMovedCallback, this);
_eventDispatcher->addEventListenerWithSceneGraphPriority(touchListener, this);


3 select 改为CC_CALLBACK_*

    CCMenuItemImage *playMenuItem = CCMenuItemImage::create(PLAY_IMAGE, PLAY_IMAGE_PRESSED, this,menu_selector(PlayMenu::play));

=>  CCMenuItemImage *playMenuItem = CCMenuItemImage::create(PLAY_IMAGE, PLAY_IMAGE_PRESSED, CC_CALLBACK_0(PlayMenu::play, this));


4 宏变更

ccBLACK  =》Color3B::BLACK


5 时间接口变更

            struct cc_timeval now;
            CCTime::gettimeofdayCocos2d(&now, NULL);

=》                 struct timeval now;
gettimeofday(&now, NULL);


3 如果增减.h .cpp 注意修改安卓下的  Android.mk文件包含,

LOCAL_SRC_FILES :

LOCAL_C_INCLUDES :



附上官方升级文档:

http://www.cocos2d-x.org/wiki/User_Tutorial-CPP_Migration_from_v2_2_*_to_v3_0

C++ MIGRATION FROM V2 2 * TO V3 0

0 0