原文链接:http://www.blogjava.net/dongbule/archive/2013/12/27/408140.html
最近接手项目从cocos2dx 2.0 升级为 3.0 ,至于为什么要升级我也弄不清楚,只感觉3.0是要摆脱cocos2d-iphone的身影,这是要作死的态度吗,没时间去了解3.0的核心发生了神马变化,只为了从cocos2dx2.0经常适应到3.0做了一些纪录,以便查阅和方便正在从2.0到3.0的朋友。
原文链接:http://www.blogjava.net/dongbule/archive/2013/12/27/408140.html
最近接手项目从cocos2dx 2.0 升级为 3.0 ,至于为什么要升级我也弄不清楚,只感觉3.0是要摆脱cocos2d-iphone的身影,这是要作死的态度吗,没时间去了解3.0的核心发生了神马变化,只为了从cocos2dx2.0经常适应到3.0做了一些纪录,以便查阅和方便正在从2.0到3.0的朋友。
2.0 CCSprite CCCallFunc CCNode .. 3.0 Sprite CallFunc Node ..@H_301_11@ 2.cc***结构体改变
2.0 ccp(x,y) ccpAdd(p1,p2) ccpSub ccpMult ccpLength(p) ccpDot(p1,p2); ccc3() ccc4() ccWHITE CCPointZero CCSizeZero 2.0 Point(x,y) p1+p2; p1-p2 p1*p2 p.getLength() p1.dot(p2) Color3B() Color4B() Color3B::WHITE Point::ZERO Size:ZERO@H_301_11@ 3.shared***改变
2.0 CCSize winSize = CCDirector::sharedDirector()->getWinSize(); SpriteFrameCache::sharedSpriteFrameCache() AnimationCache::sharedAnimationCache() NotificationCenter::sharedNotificationCenter() … 3.0 Size size = Director::getInstance()->getWinSize(); SpriteFrameCache::getInstance() AnimationCache::getInstance() NotificationCenter::getInstance() …
2.0 void setPoint(CCPoint p) 3.0 void setPoint(const Point& p)
auto dispatcher = Director::getInstance()->getEventDispatcher(); auto touchListener = EventListenerTouchOneByOne::create(); touchListener->onTouchBegan = CC_CALLBACK_2(FBMainScene::onTouchBegan,this); touchListener->onTouchMoved = CC_CALLBACK_2(FBMainScene::onTouchMoved,this); touchListener->onTouchEnded = CC_CALLBACK_2(FBMainScene::onTouchEnded,this); dispatcher->addEventListenerWithSceneGraPHPriority(touchListener,this); bool FBMainScene::onTouchBegan(Touch *touch,Event *pEvent){ CCLOG("onTouchBegan"); Point point = this->convertToWorldSpace(this->convertTouchToNodeSpace(touch)); return true; } void FBMainScene::onTouchMoved(Touch *touch,Event *pEvent){ CCLOG("onTouchMoved"); } void FBMainScene::onTouchEnded(Touch *touch,Event *pEvent){ CCLOG("onTouchEnded"); } //获得触点的方法也发生了改变: Point point = this->convertToWorldSpace(this->convertTouchToNodeSpace(touch)); //dispatcher控制方法: dispatcher->addEventListener… dispatcher->removeEventListener(listener); dispatcher->removeAllListeners();
2.0 CCMenuItemFont *item = CCMenuItemFont::create("返回上个场景",this,menu_selector(GameScene::backScene)); 3.0 MenuItemFont *item = MenuItemLabel::create("返回上个场景",CC_CALLBACK_1(GameScene::backScene,this)); // new callbacks based on C++11 #define CC_CALLBACK_0(__selector__,__target__,) std::bind(&__selector__,##__VA_ARGS__) #define CC_CALLBACK_1(__selector__,std::placeholders::_1,##__VA_ARGS__) #define CC_CALLBACK_2(__selector__,std::placeholders::_2,##__VA_ARGS__) #define CC_CALLBACK_3(__selector__,std::placeholders::_3 ##__VA_ARGS__)@H_301_11@
CallFunc::create([&](){ Sprite *sprite = Sprite::create("s"); this->addChild(sprite); });@H_301_11@
2.0 CCMoveBy *action = (CCMoveBy*) move->copy(); action->autorelease(); 3.0 action = move->clone(); 不需要autorelease,在clone已经实现。