c语言sscanf函数的用法是什么
331
2022-11-30
《cocos2dx手机游戏开发》 源码基于cocos2d-x v2.2 下载
1.效果图(动态gif和代码在底部):
《cocos2d-x手机游戏开发:跨iOS、Android和沃Phone平台》讲了一个"魔塔"游戏,它是我看的第一本关于cocos2d-x的书,“魔塔”我小时候有玩过,没有想到若干年后能看到实现方式。但是比较遗憾的是这本书使用的cocos2d-x类库比较老,是cocos2d-0.99.5-x-0.8.5。我花了一点时间把整个代码升级到cocos2d-x v2.2。想要下载的童鞋直接拉到最底部进行下载。下面是部分新老API的变化。这种大量抛弃老API的方式还是第一次见到,不过我想这是移动开发的必然吧,新老API都存在,会影响类库文件大小,效率等。
2.部分cocos2d-x代码升级示例
2.1创建一个指针基本都用create,或者函数名带有create
//old GameLayer *gamelayer = GameLayer::node();//newGameLayer *gamelayer = GameLayer::create();//oldLAYER_NODE_FUNC(GameLayer);//newCREATE_FUNC(GameLayer);//oldCCLayerColor* fadeLayer = CCLayerColor::layerWithColor(ccc4(0, 0, 0, 0));//newCCLayerColor* fadeLayer = CCLayerColor::create(ccc4(0, 0, 0, 0));//oldCCAction* action = CCSequence::actions( CCFadeIn::actionWithDuration(0.5f), CCCallFunc::actionWithTarget(this, callfunc_selector(GameScene::resetGameLayer)), NULL);//newCCAction* action = CCSequence::create( CCFadeIn::create(0.5f), CCCallFunc::create(this, callfunc_selector(GameScene::resetGameLayer)), NULL); //oldheroSprite = CCSprite::spriteWithSpriteFrame(defaultFrame)//newheroSprite = CCSprite::createWithSpriteFrame(defaultFrame);//oldCCAnimation* animation = new CCAnimation();animation->initWithFrames(animFrames, 0.1f);//newCCAnimation* animation = CCAnimation::createWithSpriteFrames(animFrames, 0.1f);//oldreturn cocos2d::CCAnimate::actionWithAnimation(anim);//newreturn cocos2d::CCAnimate::create(anim);//oldnpcSprite = CCSprite::spriteWithFile(imagePath->m_sString.c_str(), rect);//newnpcSprite = CCSprite::create(imagePath->m_sString.c_str(), rect);//oldframe0 = CCSpriteFrame::frameWithTexture(heroTexture, cocos2d::CCRectMake(32*0, 32*direction, 32, 32));//newframe0 = CCSpriteFrame::createWithTexture(heroTexture, cocos2d::CCRectMake(32*0, 32*direction, 32, 32));//oldCCMenuItemImage::itemFromNormalImageCCMenu* pMenu = CCMenu::menuWithItems(pCloseItem, NULL);CCMenuItem *down = CCMenuItemFont::itemFromString("down", this, menu_selector(ControlLayer::menuCallBackMove));//newCCMenuItemImage *pCloseItem = CCMenuItemImage::createCCMenu* pMenu = CCMenu::create(pCloseItem, NULL);CCMenuItem *down = CCMenuItemFont::create("down", this, menu_selector(ControlLayer::menuCallBackMove));//oldmap = CCTMXTiledMap::tiledMapWithTMXFile("0.tmx");//newmap = CCTMXTiledMap::create("0.tmx");
2.2 取消了CCMutableArray,借用CCArray来代替。遍历方式也变了
CCMutableArray使用有点像stl 中的vector,需要定义一个类型,CCArray全是CCObject,需要用什么类型都要转换。遍历数组方式也变了,之前的像stl中的iterator,升级后使用CCARRAY_FOREACH宏。
//oldenemyArray = new CCMutableArray
2.3CCMutableDictionary换成CCDictionary
这个也变化较大,感觉cocos2d-x慢慢去掉了C++的stl风格。
//oldteleportDict = new CCMutableDictionary
2.4cocos2d::ccTime统一用float进行代替。
//oldvoid Hero::updateOpenDoorAnimation(ccTime dt)//newvoid Hero::updateOpenDoorAnimation(float dt)
2.5一些get、set函数发生改变,比如setIsVisible变成setVisible等;
//oldfightSprite->setIsVisible(false);//newfightSprite->setVisible(false);
3.0 《cocos2dx手机游戏开发》v2.2 源码下载(请用7z解压,rar可能会有错误)
4.0 动态图赏析
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~