Differences between cocos2d-x3.0 and 2.0

Source: Internet
Author: User

Differences between cocos2d-x3.0 and 2.0


Difference 1. CC Removal

<喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD48cD48YnIgLz48L3A + PHA + expires + bG + expires = "brush: java;"> 2.0 CCSprite CCCallFunc CCNode... 3.0 Sprite CallFunc Node ..

Difference 2. cc *** Structure Change

2.0        ccp(x,y)        ccpAdd(p1,p2)ccpSubccpMultccpLength(p)ccpDot(p1,p2);ccc3()ccc4()ccWHITECCPointZeroCCSizeZero3.0Point(x,y)p1+p2;p1-p2p1*p2p.getLength()p1.dot(p2)Color3B()Color4B()Color3B::WHITEPoint::ZEROSize:ZERO


Difference 3. shared *** changes (the single-instance mechanism uses the syntax)

2.0CCSize winSize = CCDirector::sharedDirector()->getWinSize();SpriteFrameCache::sharedSpriteFrameCache()AnimationCache::sharedAnimationCache()NotificationCenter::sharedNotificationCenter()…3.0Size size = Director::getInstance()->getWinSize();SpriteFrameCache::getInstance()AnimationCache::getInstance()NotificationCenter::getInstance()…


Difference 4. POD category

2.0CCPoint CCSizeCCRect3.0Vec2SizeRect


Difference 5. Touch events

Auto dispatcher = Director: getInstance ()-> getEventDispatcher (); auto touchListener = listener: 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-callback (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 ");} // The method for obtaining the contact has also changed: Point point = this-> c OnvertToWorldSpace (this-> convertTouchToNodeSpace (touch); // dispatcher control method: dispatcher-> addEventListener... Dispatcher-> removeEventListener (listener); dispatcher-> removeAllListeners ();


Difference 6. Callback Functions

The CC_CALLBACK_0 CC_CALLBACK_1 CC_CALLBACK_2 CC_CALLBACK_3 callback function carries different parameters for convenience

2.0 CCMenuItemFont * item = CCMenuItemFont: create ("back to the previous scenario", this, menu_selector (GameScene: backScene); 3.0 MenuItemFont * item = MenuItemLabel :: create ("return the previous scenario", CC_CALLBACK_1 (GameScene: backScene, this); // new callbacks based on C ++ 11 # define CC_CALLBACK_0 (_ selector __, __target __,) std: bind (& __ selector __,__ target __,#__va_args _) # define CC_CALLBACK_1 (_ selector __,__ target __,) std: bind (& __ selector __,__ target __, std: placeholders: _ 1, ##__va_args _) # define CC_CALLBACK_2 (_ selector __, __target __,) std: bind (& __ selector __,__ target __, std: placeholders: _ 1, std: placeholders: _ 2, ##__ VA_ARGS _) # define CC_CALLBACK_3 (_ selector __,__ target __,) std: bind (&__ selector __,__ target __, std: placeholders:: _ 1, std: placeholders: _ 2, std: placeholders: _ 3 #__va_args __)


Difference 7. CallFunc usage (using a "Function" Object)

CallFunc::create([&](){        Sprite *sprite = Sprite::create("s");        this->addChild(sprite);});


Difference 8. Replace copy with clone

2.0 CCMoveBy * action = (CCMoveBy *) move-> copy (); action-> autorelease (); 3.0 action = move-> clone (); autorelease is not required, the clone has been implemented.


Difference 9. Physics Integration physical Engine

Currently unavailable. box2d can be used in 3.0. You need to define PhysicsWorld, PhysicsBody, PhysicsShape, and PhysicsJoint in 3.0 Physics. Similar to box2d, You need to define CC_USE_PHYSICS before use.



Difference 10. Container

2.0CCArray3.0cocos2d::Vector
 
  cocos2d::Map
  
   cocos2d::Value
  
 

Learning ...... Continue to wait for Supplement.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.