删除了CC前缀
CCAction
CCString 改变
CCAction
-> Action
CCPoint
-> Point
CCAnimation
-> Animation
CCSprite
-> Sprite
cclabel
-> Label
Ccmenu
-> Menu
CCObject
-> Ref
CCNode
-> Node
CCScene
-> Scene
cclayer
-> Layer
CCSpriteBatchNoe
-> SpriteBatchNode
CCTMXTiledMap
-> TMXTiledMap
CCDictionary
-> ValueMap
CCArray
-> ValueVector
CCString
-> Value
之前:
CCString* str = CCString::createWithFormat("%s.png","picture");
之后:
std::string str = StringUtils::format("%s.png","picture");CCDictionary 改变
之前:
CCDictionary* dict = CCDictionary::createWithContentsOffile("name.pList");CCArray* arr = (CCArray*) dict->objectForKey("Levels");
之后:
std::string path = fileUtils::getInstance()->fullPathForfilename("name.pList");ValueMap dict = fileUtils::getInstance()->getValueMapFromfile(path);ValueVector arrLevels = dict.at("Levels").asValueVector();CCArray 改变
改为标准的vector容器
触摸函数改变
CCArray* arr;
->ValueVector arr;
arr->addobject(sprite);
->arr.pushBack(sprite);
arr->removeObject(sprite);
->arr.eraSEObject(sprite);
arr->removeObjectAtIndex(i);
->arr.erase(i);
arr->objectAtIndex(i);
->arr.at(i);
arr->count();
->arr.size();
MenuItem 菜单 变化
cctouchBegan
->ontouchBegan
cctouchmoved
->ontouchmoved
cctouchended
->ontouchended
ccMacros.h中宏定义
// 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__)
v2调用方法
cmenuItemImage *item1 = CcmenuItemImage::create(s_pPathB1,s_pPathB2,this,menu_selector(ActionsDemo::backCallback));
v3调用方法1
MenuItemImage *item1 = MenuItemImage::create(s_pPathB1,CC_CALLBACK_1(ActionsDemo::backCallback,this));
v3调用方法2
MenuItemImage *item1 = MenuItemImage::create(s_pPathB1,[=](Ref* sender){ //code here }););
全局单例类的改变 CCTime 改变
CCEGLVIEw::sharedOpenGLVIEw();
->Director::getInstance()->getopenGLVIEw();
CCTextureCache::sharedTextureCache();
->Director::getInstance()->getTextureCache();
CCNotificationCenter::sharednotificationCenter();
->Director::getInstance()->getEventdispatcher();
Configuration::sharedConfiguration
->Configuration::getInstance
Configuration::purgeConfiguration
->Configuration::destroyInstance
Director::sharedDirector
->Director::getInstance
fileUtils::sharedfileUtils
->fileUtils::getInstance
fileUtils::purgefileUtils
->fileUtils::destroyInstance
EGLVIEw::sharedOpenGLVIEw
->EGLVIEw::getInstance
shadercache::sharedshadercache
->shadercache::getInstance
shadercache::purgeSharedshadercache
->shadercache::destroyInstance
AnimationCache::sharedAnimationCache
->AnimationCache::getInstance
AnimationCache::purgeSharedAnimationCache
->AnimationCache::destroyInstance
SpriteFrameCache::sharedSpriteFrameCache
->SpriteFrameCache::getInstance
SpriteFrameCache:: purgeSharedSpriteFrameCache
->SpriteFrameCache::destroyInstance
NotificationCenter::sharednotificationCenter
->NotificationCenter::getInstance
NotificationCenter:: purgeNotificationCenter
->NotificationCenter::destroyInstance
Profiler::sharedProfiler
->Profiler::getInstance
UserDefault::sharedUserDefault
->UserDefault::getInstance
UserDefault::purgeSharedUserDefault
->UserDefault::destroyInstance
Application::sharedApplication
->Application::getInstance
kBlendFuncdisable
->BlendFunc::BLEND_FUNC_disABLE
cc_timeval
->timeval
CCTime::gettimeofdayCocos2d
->gettimeofday
CCTime::timesubCocos2d
->getTimeDiffenceMS
事例:
static inline float getTimeDifferenceMS(timeval& start,timeval& end){ return ((((end.tv_sec - start.tv_sec)*1000.0f + end.tv_usec) - start.tv_usec) / 1000.0f);}
OpenGL 变化 一般做游戏不太涉及得到
函数对照 点 *** 作
CCGLProgram
->GLProgram
kCCUniformPMatrix_s
->GLProgram::UNIFORM_name_P_MATRIX
kCCUniformMVMatrix_s
->GLProgram::UNIFORM_name_MV_MATRIX
kCCUniformMVPMatrix_s
->GLProgram::UNIFORM_name_MVP_MATRIX
kCCUniformTime_s
->GLProgram::UNIFORM_name_TIME
kCCUniformSinTime_s
->GLProgram::UNIFORM_name_SIN_TIME
kCCUniformCosTime_s
->GLProgram::UNIFORM_name_COS_TIME
kCCUniformRandom01_s
->GLProgram::UNIFORM_name_RANDOM01
kCCUniformSampler_s
->GLProgram::UNIFORM_name_SAMPLER0
kCCUniformAlphaTestValue
->GLProgram::UNIFORM_name_Alpha_TEST_VALUE
kCCAttributenamecolor
->GLProgram::ATTRIBUTE_name_color
kCCAttributenameposition
->GLProgram::ATTRIBUTE_name_position
kCCAttributenameTexCoord
->GLProgram::ATTRIBUTE_name_TEX_COORD
色彩 *** 作点
ccp
->Vec2
点负数ccpNeg
->Vect::negate or -
点相加ccpAdd
->Vect::add or +
点相减ccpsub
->Vect::subtract or -
点相乘ccpMult
->Vect::*
点获得中点ccpMIDpoint
->Vect::getMIDpoint
点积ccpDot
->Vect::dot
叉积ccpCrosss
->Vect::cross
逆时针旋转90度ccpPerp
->Vect::getPerp
顺时针旋转90度ccpRPerp
->Vect::getRPerp
投影ccpProject
->Vect::project
ccpRotate
->Vect::rotate
ccpunrotate
->Vect::unrotate
长度未开方(点积)ccpLengthSQ
->Vect::getLengthSq
距离未开方ccpdistanceSQ
->distanceSquared
长度ccpLength
->getLength
距离ccpdistance
->getdistance
取模ccpnormalize
->normalize
从角度获得ccpForAngle
->forAngle
转换为角度ccpToAngle
->getAngle
ccpClamp
->getClampPoint
ccpFromSize
->无
对x,y值进行函数处理ccpCompOp
->compOp
两点构成直线上的点ccpLerp
->lerp
模糊相等,两个点靠的足够近ccpFuzzyEqual
->fuzzyEqual
ccpCompMult
->无
和x轴的夹角或者和向量组成的夹角ccpAngleSigned
->getAngle
同上ccpAngle
->getAngle
旋转角度ccpRotateByAngle
->rotateByAngle
线是否相交/四个点是否在一个平面ccplineInersect
->islineIntersect
线段是否相交/四个点是否在一个平面ccpsegmentIntersect
->isSegmentIntersect
获取线段交点ccpIntersectPoint
->getIntersectPoint
CCPointMake
->无
用宏定义来查找API变化
ccc3()
->color3B()
ccc3BEqual()
->color3B::equals()
ccc4()
->color4B()
ccc4f()
->color4F()
ccc4FEqual()
->color4F::equals()
ccwHITE
->color3B::WHITE
ccYELLOW
->color3B::YELLOW
ccBLUE
->color3B::BLUE
ccGREEN
->color3B::GREEN
ccRED
->color3B::RED
ccmagenta
->color3B::magenta
ccBLACK
->color3B::BLACK
ccORANGE
->color3B::ORANGE
ccGRAY
->color3B::GRAY
ccc4FFromccc3B
->无
ccc4FFromccc4B
->无
ccc4BFromccc4F
->无
全局搜索 CC_DEPRECATED_ATTRIBUTE
参考:
cocos2d-x v2 和 v3 对照手册
升级到Cocos2d-x v3.3-RC0总结Director的主线解析
cocos2dx2.x&3.x部分函数对照表
以上是内存溢出为你收集整理的cocos2d-x v2 升级到 v3全部内容,希望文章能够帮你解决cocos2d-x v2 升级到 v3所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)