Cocos2d-x2.0.2与升级前的代码差异

           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))

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值