关于cocos2d-x3.0和2.0之间的区别
1个回答
展开全部
区别1.去CC
之前2.0的CC**,把CC都去掉,基本的元素都是保留的
2.0
CCSprite CCCallFunc CCNode ..
3.0
Sprite CallFunc Node ..
区别2.cc***结构体改变
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***改变(单例机制使用语法)
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()
区别4.POD类别
2.0
CCPoint
CCSize
CCRect
3.0
Vec2
Size
Rect
区别5.点触事件
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();
区别6.CallFunc使用(使用"Function"对象)
CallFunc::create([&](){
Sprite *sprite = Sprite::create("s");
this->addChild(sprite);
});
区别7.使用clone代替copy
2.0
CCMoveBy *action = (CCMoveBy*) move->copy();
action->autorelease();
3.0
action = move->clone();
不需要autorelease,在clone已经实现。
区别8.Physics Integration 物理引擎
暂无使用,box2d 在 3.0中可以延续使用
在3.0的Physics中需要定义 PhysicsWorld, PhysicsBody, PhysicsShape, PhysicsJoint 等,于box2d相仿,使用前需要定义CC_USE_PHYSICS
区别9.容器
2.0
CCArray
3.0
cocos2d::Vector<T>
cocos2d::Map<K,V>
cocos2d::Value
之前2.0的CC**,把CC都去掉,基本的元素都是保留的
2.0
CCSprite CCCallFunc CCNode ..
3.0
Sprite CallFunc Node ..
区别2.cc***结构体改变
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***改变(单例机制使用语法)
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()
区别4.POD类别
2.0
CCPoint
CCSize
CCRect
3.0
Vec2
Size
Rect
区别5.点触事件
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();
区别6.CallFunc使用(使用"Function"对象)
CallFunc::create([&](){
Sprite *sprite = Sprite::create("s");
this->addChild(sprite);
});
区别7.使用clone代替copy
2.0
CCMoveBy *action = (CCMoveBy*) move->copy();
action->autorelease();
3.0
action = move->clone();
不需要autorelease,在clone已经实现。
区别8.Physics Integration 物理引擎
暂无使用,box2d 在 3.0中可以延续使用
在3.0的Physics中需要定义 PhysicsWorld, PhysicsBody, PhysicsShape, PhysicsJoint 等,于box2d相仿,使用前需要定义CC_USE_PHYSICS
区别9.容器
2.0
CCArray
3.0
cocos2d::Vector<T>
cocos2d::Map<K,V>
cocos2d::Value
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询