cocos2d-x3.0和2.0之间的区别

区别1.去CC


区别2.cc***结构体改变

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
2.0
ccp(x,y)
ccpAdd(p1,p2)
ccpSub
ccpMult
ccpLength(p)
ccpDot(p1,p2);
ccc3()
ccc4()
ccWHITE
CCPointZero
CCSizeZero
3.0
Point(x,y)
p1+p2;
p1-p2
p1*p2
p.getLength()
p1.dot(p2)
Color3B()
Color4B()
Color3B::WHITE
Point::ZERO
Size:ZERO


区别3.shared***改变(单例机制使用语法)

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


区别4.POD类别

9
CCPoint
CCSize
CCRect
3.0
Vec2
Size
Rect



区别5.点触事件

26
27
28
auto dispatcher = Director::getInstance()->getEventDispatcher();
auto touchListener = EventListenerTouchOneByOne::create();
touchListener->onTouchBegan = CC_CALLBACK_2(FBMainScene::onTouchBegan, this );
touchListener->onTouchMoved = CC_CALLBACK_2(FBMainScene::onTouchMoved,monospace!important; font-size:1em!important; min-height:inherit!important">);
touchListener->onTouchEnded = CC_CALLBACK_2(FBMainScene::onTouchEnded,monospace!important; font-size:1em!important; min-height:inherit!important">);
dispatcher->addEventListenerWithSceneGraphPriority(touchListener,monospace!important; font-size:1em!important; min-height:inherit!important">);
bool FBMainScene::onTouchBegan(Touch *touch,Event *pEvent){
CCLOG( "onTouchBegan" );
Point point = ->convertToWorldSpace( ->convertTouchToNodeSpace(touch));
return true ;
}
void FBMainScene::onTouchMoved(Touch *touch,Event *pEvent){
"onTouchMoved" );
}
FBMainScene::onTouchEnded(Touch *touch,Event *pEvent){
"onTouchEnded" );
}
//获得触点的方法也发生了改变:
->convertTouchToNodeSpace(touch));
//dispatcher控制方法:
dispatcher->addEventListener…
dispatcher->removeEventListener(listener);
dispatcher->removeAllListeners();



区别6.回调函数

CC_CALLBACK_0 CC_CALLBACK_1 CC_CALLBACK_2 CC_CALLBACK_3回调函数,分别携带不同的参数,方便

10
CCMenuItemFont *item = CCMenuItemFont::create( "返回上个场景" ,menu_selector(GameScene::backScene));
3.0
MenuItemFont *item = MenuItemLabel::create( ));
// 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__)

区别7.CallFunc使用(使用"Function"对象)

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


区别8.使用clone代替copy

4
5
6
2.0
CCMoveBy *action = (CCMoveBy*) move->copy();
action->autorelease();
3.0
action = move->clone();
不需要autorelease,在clone已经实现。


区别9.Physics Integration 物理引擎

2
暂无使用,box2d 在 3.0 中可以延续使用
的Physics中需要定义 PhysicsWorld,PhysicsBody,PhysicsShape,PhysicsJoint 等,于box2d相仿,使用前需要定义CC_USE_PHYSICS


区别10.容器

6
7
8
CCArray
3.0
cocos2d::Vector<t>
cocos2d::Map<k,v>
cocos2d::Value</k,v></t>

相关文章

    本文实践自 RayWenderlich、Ali Hafizji 的文章《...
Cocos-code-ide使用入门学习地点:杭州滨江邮箱:appdevzw@1...
第一次開始用手游引擎挺激动!!!进入正题。下载资源1:从C...
    Cocos2d-x是一款强大的基于OpenGLES的跨平台游戏开发...
1.  来源 QuickV3sample项目中的2048样例游戏,以及最近《...
   Cocos2d-x3.x已经支持使用CMake来进行构建了,这里尝试...