Cocos2d-x2.0.2与升级前的代码差异
——比较常见的
1、
heroSprite=CCSprite::spriteWithSpriteFrame(walkAnimation[kDown]->getFrames()->getObjectAtIndex(0));
变成:heroSptite = CCSprite::createWithSpriteFrame((CCSpriteFrame *)walkAnimation[kDown] ->getFrames()->objectAtIndex(0));
2、
frame0=CCSpriteFrame::frameWithTexture(heroTexture,cocos2d::CCRectMake(32*0,32*direction, 32, 32));
变成:frame0 = CCSpriteFrame::createWithTexture(heroTexture, cocos2d::CCRectMake(32*0, 32*direction, 32, 32));
3、
CCMutableArray<CCSpriteFrame*>*animFrames=new CCMutableArray<CCSpriteFrame*>(4);
变成:CCArray* animFrames = new CCArray(4);
4、CCMenuItem *down = CCMenuItemFont::itemFromString("down",this,menu_selector(MTGame::menuCallBackMove));
变成:CCMenuItem *down = CCMenuItemFont::create("down",this,menu_selector(MTGame::menuCallBackMove));
5、
animation->initWithFrames(animFrames, 0.2f);
变成:animation->createWithSpriteFrames(animFrames, 0.2f);
6、
snakeSprite->setIsVisible(isVisible); this->setIsTouchEnabled(true);
变成:snakeSprite->setVisible(isVisible); this->setTouchEnabled(true);
7、
CCTouchDispatcher::sharedDispatcher()->addTargetedDelegate(this, 0, false);
变成:CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this, 0, false);
8、
CCScene*scene=NULL;do{scene=CCScene::node();CC_BREAK_IF(!scene);GameScene*layer=GameScene::node();CC_BREAK_IF(!layer); scene->addChild(layer); }while(0);
变成:CCScene*scene=NULL;do{ scene=CCScene::create(); CC_BREAK_IF(!scene);GameScene*layer=GameScene::create();CC_BREAK_IF(!layer); scene->addChild(layer); }while(0);
9、
this->runAction(CCSequence::actions(CCMoveTo::actionWithDuration(ccpDistance(this->getPosition(),target)/velocity,target),CCCallFunc::actionWithTarget(this,callfunc_selector(Player::removeTarget)), NULL));
变成:this->runAction(CCSequence::create(CCMoveTo::create(ccpDistance(this->getPosition(), target) / velocity, target),CCCallFunc::create(this, callfunc_selector(Player::removeTarget)), NULL))