cocos2d-x cpp 3.*相较于2.*的区别(整理)
来源:互联网 发布:福州理工学院网络 编辑:程序博客网 时间:2024/05/21 12:42
截至笔者写这篇文章的时间,cocos2d-x 的两个最新版本 分别是
Download v3.0rc1
Download v2.2.3
运行环境需求:
- Android 2.3 or newer
- iOS 5.0 or newer
- OS X 10.7 or newer
- Windows (which version?)
- Linux Ubuntu 12.04 (or newer)
- Xcode 4.6 (for iOS or Mac)
- gcc 4.7 for Linux or Android. For Android ndk-r8e or newer is required.
- Visual Studio 2012 (for Windows)
- Replace Objective-C patters with C++ (C++11) patterns and best practices
- Improve Labels
- Improve renderer
A subset of C++11 features are being used in cocos2d-x:
std::function
, including lambda objects for callbacks- strongly typed enums, for most of the cocos2d-x enums and constants
std::thread
for threadingoverride
context keyword, for overriden methods
st std::function
CallFunc
can be created with anstd::function<void()>
CallFuncN
can be created with anstd::function<void(Node*)>
CallFuncND
andCallFuncO
were removed since it can be created with simulated withCallFuncN
andCallFunc
. See ActionsTest.cpp for more examplesMenuItem
supportsstd::function<void(Node*)>
as callbacks
kCCTexture2DPixelFormat_RGBA8888
Texture2D::PixelFormat::RGBA8888
kCCDirectorProjectionCustom
Director::Projection::CUSTOM
ccGREEN
Color3B::GREEN
CCPointZero
Point::ZERO
CCSizeZero
Size::ZERO
The old values can still be used, but are not deprecated.
Removed Objective-C patterns
移除了所有Object-c模式,删除了CC前辍使用纯C++函数clone() instead of copy()
clone()
returns an autoreleased version of the copy.
copy()
is no longer supported. If you use it, it will compile, but the code will crash.
Example:
Singletons use getInstance() and destroyInstance()
All singletons use getInstance()
and destroyInstance()
(if applicable) to get and destroy the instance.
Examples:
v2.1v3.0CCDirector->sharedDirector()
Director->getInstance()
CCDirector->endDirector()
Director->destroyInstance()
etc...v2.1 methods are still available, but they were tagged as deprecated.
getters
Getters now use the get
prefix.
Examples:
v2.1v3.0node->boundingBox()
node->getBoundingBox()
sprite->nodeToParentTransform()
sprite->getNodeToParentTransform()
etc...And getters were also tagged as const
in their declaration. Example:
v2.1 methods are still available, but they were tagged as deprecated.
POD types
Methods that were receiving POD types as arguments (eg: TexParams
, Point
, Size
, etc.) are being passed as const
reference.
Example:
Misc API Changes
ccTypes.h
Remove cc prefix for structure names in ccTypes.h, move global functions into static member functions, and move global constants into const static member variables.
structure name before changingstructure name after changingccColor3B
Color3B
ccColor4B
Color4B
ccColor4F
Color4F
ccVertex2F
Vertex2F
ccVertex3F
Vertex3F
ccTex2F
Tex2F
ccPointSprite
PointSprite
ccQuad2
Quad2
ccQuad3
Quad3
ccV2F_C4B_T2F
V2F_C4B_T2F
ccV2F_C4F_T2F
V2F_C4F_T2F
ccV3F_C4B_T2F
V3F_C4B_T2F
ccV2F_C4B_T2F_Triangle
V2F_C4B_T2F_Triangle
ccV2F_C4B_T2F_Quad
V2F_C4B_T2F_Quad
ccV3F_C4B_T2F_Quad
V3F_C4B_T2F_Quad
ccV2F_C4F_T2F_Quad
V2F_C4F_T2F_Quad
ccBlendFunc
BlendFunc
ccT2F_Quad
T2F_Quad
ccAnimationFrameData
AnimationFrameData
Global functions changed example
deprecated functions and global variables
old namenew nameccp
Point
ccpNeg
Point::-
ccpAdd
Point::+
ccpSub
Point::-
ccpMult
Point::*
ccpMidpoint
Point::getMidpoint
ccpDot
Point::dot
ccpCrosss
Point::cross
ccpPerp
Point::getPerp
ccpRPerp
Point::getRPerp
ccpProject
Point::project
ccpRotate
Point::rotate
ccpUnrotate
Point::unrotate
ccpLengthSQ
Point::getLengthSq()
ccpDistanceSQ
Point::getDistanceSq
ccpLength
Point::getLength
ccpDistance
Point::getDistance
ccpNormalize
Point::normalize
ccpForAngle
Point::forAngle
ccpToAngle
Point::getAngle
ccpClamp
Point::getClampPoint
ccpFromSize
Point::Point
ccpCompOp
Point::compOp
ccpLerp
Point::lerp
ccpFuzzyEqual
Point::fuzzyEqual
ccpCompMult
Point::Point
ccpAngleSigned
Point::getAngle
ccpAngle
Point::getAngle
ccpRotateByAngle
Point::rotateByAngle
ccpLineInersect
Point::isLineIntersect
ccpSegmentIntersect
Point::isSegmentIntersect
ccpIntersectPoint
Point::getIntersectPoint
CCPointMake
Point::Point
CCSizeMake
Size::Size
CCRectMake
Rect::Rect
PointZero
Point::ZERO
SizeZero
Size::ZERO
RectZero
Rect::ZERO
TiledGrid3DAction::tile
TiledGrid3DAction::getTile
TiledGrid3DAction::originalTile
TiledGrid3DAction::getOriginalTile
TiledGrid3D::tile
TiledGrid3D::getTile
TiledGrid3D::originalTile
TiledGrid3D::getOriginalTile
Grid3DAction::vertex
Grid3DAction::getVertex
Grid3DAction::originalVertex
Grid3DAction::getOriginalVertex
Grid3D::vertex
Grid3D::getVertex
Grid3D::originalVertex
Grid3D::getOriginalVertex
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
ccc3()
Color3B()
ccc3BEqual()
Color3B::equals()
ccc4()
Color4B()
ccc4FFromccc3B()
Color4F()
ccc4f()
Color4F()
ccc4FFromccc4B()
Color4F()
ccc4BFromccc4F()
Color4B()
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
kBlendFuncDisable
BlendFunc::BLEND_FUNC_DISABLE
--------------------------------------------------------------------------------------------------------(1)字符传参 使用 const std::string& str;看实例:
- //设置缓存批处理
- cocos2d::SpriteBatchNode* setCache_batch(const std::string& plist,const std::string& pvr);
- SpriteBatchNode* Base::setCache_batch(const std::string& plist, const std::string& pvr)
- {
- auto cache=SpriteFrameCache::getInstance();
- cache->addSpriteFramesWithFile(plist);
- auto batchNode=SpriteBatchNode::create(pvr);
- return batchNode;
- }
(2):for循环有点类似python脚本:看实例:
- const std::string& str =" ni hao p";
- for(auto &t :str)//从容器中引用对象
- log("%c",str);
- 控制台打印:
- n
- i
- h
- a
- o
- p
(3):获取导演和缓存时,废除了share 改为 getInstance(); 实例:
CCDirector::getInstance();
- SpriteFrameCache::getInstance();
(4):获取地图的图层时:废弃了laynamed("");改为 getLayer("");实例:
- _myMap=TMXTiledMap::create("map/allmap1.tmx");
- _myMap->setScale(1.7f);
- _myMap->getLayer("barry")->setVisible(false);
(5):从精灵框帧缓存中创建动画时,废弃了原来的数组,改用向量来创建,大部分情况下还是使用数组
实例:
有时间再补,睡觉.....
- cocos2d-x cpp 3.*相较于2.*的区别(整理)
- L1相较于L2的稀疏性
- cocos2D-x关于CCSpriteFrame的cpp实现
- 有关于Cocos2d-X的几个坑(2016.1.26)
- 【Cocos2d入门教程十三】 浅析Cocos2d下3.x与2.x屏幕截图的区别
- 让 cocos2d-x 2.X 版本能使用 physicsEditor (修改文件 GB2ShapeCache-x.cpp)
- 相较于其他语言,golang的突出特点和优势
- Swift 3.0 【Swift 3.0 相较于 Swift 2.2 的变化】
- 1.jdbc相较于mybatis,hibernate的一些缺点
- linux相较于windows作为服务器端操作系统的优点
- IOS系统相较于Android系统的优势
- Rhyme/Java 继承相较于组合的优势在哪里?
- cocos2d-x独立于场景的节点
- 关于cocos2d-x 2.x与3.x之间的区别
- 学习笔记 cocos2d-x 2.x到3.x的改动与区别
- cocos2d-x触摸事件addTouchEventListener在2.x和3.x的区别
- Cocos2d-x 3.x 资料整理
- cocos2d-x常见的报错(收集整理)
- SpringMVC介绍之Validation
- win7下制作ubuntu系统安装启动盘和U盘安装ubuntu全过程
- 给老板做一个报告
- Box2D C++ 教程-旋转到指定角度
- cmd 提示“不是内部或外部命令,也不是可运行的程序或批处理文件”
- cocos2d-x cpp 3.*相较于2.*的区别(整理)
- HTML5基础教程系列:第3部分,HTML5 API的威力
- C语言的谜题
- 浏览器不兼容
- 第五周作业—有向图邻接表表示及反向图构造
- UNREFERENCED_PARAMETER
- android的TableLayout布局界面元素填满整个屏幕
- python 发送Email程序
- Window Android 学习