大佬教程收集整理的这篇文章主要介绍了cocos2d-x v3.0新特性及使用,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
八月份cocos2d-x官网发布了v3.0版本,这次更新的内容特别多,包括2dx的架构以及使用
总得来说,给开发者带来了很大的便利:
运行环境需求:
A subset of C++11 features are being used in cocos2d-x:
std::function
,including lambda objects for callBACksstd::thread
for threadingoverride
context keyword,for overriden methodsCallFunc
can be created with anstd::function<void()>
std::function<void(Node*)>
CallFuncND
andCallFuncO
were removed since it can be created with simulated withCallFuncN
andCallFunc
. See ActionsTest.cpp for more examplesstd::function<void(Node*)>
as callBACks
v2.1 | v3.0 |
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.
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:
All singletons usegeTinstance()
anddestroyInstance()
(if applicablE) to get and destroy the instance.
Examples:
Director->geTinstance() | |
CCDirector->endDirector() | Director->destroyInstance() |
etc... |
v2.1 methods are still available,but they were tagged as deprecated.
Getters now use theget
prefix.
node->boundingBox()
const
in their declaration. Example:
POD types
@H_945_58@methods that were receiving POD types as arguments (eg:TexParams
,Point
,250)">Size,etc.) are being passed asconst
reference.
Example:
void setTexParameters(ccTexParams* texParams); void setTexParameters(const ccTexParams& texParams);
ccTypes.h
Removeccprefix 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 changing | structure name after changing |
ccColor3B | 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
1 2// in v2.1 3ccColor3B color3B = ccc3(0,0); 4ccc3BEqual(color3B,1,207)">1)); 5ccColor4B color4B = ccc4(0); 6ccColor4F color4F = ccc4f( 7color4F = ccc4FFromccc3B(color3B); 8color4F = ccc4FFromccc4B(color4B); 9ccc4FEqual(color4F,ccc4F(10color4B = ccc4BFromccc4F(color4F); 11 12color3B = ccWHITE; 13 14// in v3.0 15Color3B color3B = Color3B(16color3B.equals(Color3B(17Color4B color4B = Color4B(18Color4F color4F = Color4F(19color4F = Color4F(color3B); 20color4F = Color4F(color4B); 21color4F.equals(Color4F(22color4B = Color4B(color4F); 23 24color3B = Color3B::WHITE;
new name | ||||
ccp | Point | |||
ccpNeg | Point::- | |||
ccpAdd | Point::+ | |||
ccpSub | 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 | ccpAngleSigned | ccpAngle | ccpRotateByAngle | Point::rotateByAngle |
ccpLineInersect | Point::isLineIntersect | |||
ccpSegmenTintersect | Point::isSegmenTintersect | |||
ccpIntersectPoint | Point::geTintersectPoint | |||
CCPointMake | CCSizeMake | Size::Size | ||
CCRectMake | Rect::rect | |||
PointZero | 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() | ccc4FFromccc4B() | ccc4BFromccc4F() | ccc4FEqual() | Color4F::equals() |
ccWHITE | Color3B::WHITE | |||
ccYELLOW | Color3B::YELLOW | |||
ccBLUE | Color3B::BLUE | |||
ccRED | Color3B::rED | |||
ccMAGENTA | Color3B::MAGENTA | |||
ccBLACK | Color3B::BLACK | |||
ccORANGE | Color3B::ORANGE | |||
ccGRAY | Color3B::GRAY | |||
kBlendFuncDisable | BlendFunc::BLEND_FUNC_DISABLE |
以上是大佬教程为你收集整理的cocos2d-x v3.0新特性及使用全部内容,希望文章能够帮你解决cocos2d-x v3.0新特性及使用所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。