原因:要送个消消乐游戏给人,有个现成的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,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》