cocos2dx[3.2](4) ——浅析CCDeprecated.h

发布时间:2020-06-11 04:27:39 作者:shahdza
来源:网络 阅读:3311

【唠叨】

    CCDeprecated.h中存放的都是2.x将要被抛弃的命名规范,主要包含类名、枚举类型。

    虽然说2.x的这些命名规范被CCDeprecated.h保留了。但是为了彻底学习3.x的新特性,就必须要尽量不要使用2.x的命名规范。

    有些变更其实已经在:cocos2dx[3.x](3)——大巨变3.x 中做了详细的说明了。




【CCDeprecated.h】


1、主要的变更有以下几个方面

    (1)去掉C++类的 "CC" 前缀

    (2)去掉全局函数及常量的 "cc" 前缀,均变为 相应类 中的静态成员函数及常量。

    (3)去掉坐标运算的函数 "ccp" 前缀 ,均变为 Vec2类 中的静态成员函数及常量。

    (4)去掉绘图原语的 "ccDraw" 前缀  ,使用 DrawPrimitives 命名空间。

    (5)去掉OpenGL原语的 "ccGL" 前缀  ,使用 GL 命名空间。

    (6)以 "k" 开头的常量和枚举量,现在均由强枚举类型替代。

    (7)其他改动

    这些改动的详细说明,请参照:cocos2dx[3.x](3)——大巨变3.x


2、一些特殊的改动


  2.1、类名替代

    > Clonable 替代 CCCopying

        CCCopying已经永久的被遗弃了,没有被保留下来。

    > Ref 替代 Object

        虽然CCObject被保留了(typedef Ref Object),但是以后就不要再用了,使用 Ref 吧!

        Object命名也即将被遗弃。

    > Vec2 替代 Point

        其中:Vec2代表了2D坐标系,Vec3则是代表了3D坐标系。

        Point命名也即将被遗弃。

    > GLProgramCache 替代 ShaderCache

        其中着色器类为GLProgram

        ShaderCache命名也即将被遗弃。

    > GLView 替代 CCEGLView


  2.2、整合

    > 对 Node 进行了整合

        typedef Node CCNode;

        typedef Node CCNodeRGBA;

        typedef Node CCRGBAProtocol;

        可见,在3.x中已经将CCNodeRGBA、CCRGBAProtocol两个类整合到了Node类中。

        即:在Node类中增加了颜色、透明度的控制:setColor(Color3B&)、setOpacity()。

    > 对 Layer 进行了整合

        typedef Layer CCLayer;

        typedef Layer CCLayerRGBA;

        可见,在3.x中已经将CCLayerRGBA类整合到了Layer类中。

        即:在Layer类中增加了颜色、透明度的控制:setColor(Color3B&)、setOpacity()。


  2.3、强枚举类型替代 "k"

    以下列举一些枚举类型的变更,更多详细的变更,请自己参考 CCDeprecated.h 文件。

    当然 "k" 开头的枚举变量命名也即将被遗弃。

//ccDirectorProjection

typedef Director::Projection   ccDirectorProjection;

kCCDirectorProjection2D      = Director::Projection::_2D;

kCCDirectorProjection3D      = Director::Projection::_3D;

kCCDirectorProjectionCustom  = Director::Projection::CUSTOM;

kCCDirectorProjectionDefault = Director::Projection::DEFAULT;


//CCVerticalTextAlignment

typedef TextVAlignment           CCVerticalTextAlignment;

kCCVerticalTextAlignmentTop    = TextVAlignment::TOP;

kCCVerticalTextAlignmentCenter = TextVAlignment::CENTER;

kCCVerticalTextAlignmentBottom = TextVAlignment::BOTTOM;


//CCTextAlignment

typedef TextHAlignment   CCTextAlignment;

kCCTextAlignmentLeft   = TextHAlignment::LEFT;

kCCTextAlignmentCenter = TextHAlignment::CENTER;

kCCTextAlignmentRight  = TextHAlignment::RIGHT;


//ProgressTimerType

typedef ProgressTimer::Type  ProgressTimerType;

kCCProgressTimerTypeRadial = ProgressTimer::Type::RADIAL;

kCCProgressTimerTypeBar    = ProgressTimer::Type::BAR;


//ParticleSystem

ParticleSystem::Mode 

kCCParticleModeGravity = ParticleSystem::Mode::GRAVITY;

kCCParticleModeRadius  = ParticleSystem::Mode::RADIUS;


ParticleSystem::PositionType

kCCPositionTypeFree     =  ParticleSystem::PositionType::FREE;

kCCPositionTypeRelative =  ParticleSystem::PositionType::RELATIVE;

kCCPositionTypeGrouped  =  ParticleSystem::PositionType::GROUPED;


//TransitionScene

TransitionScene::Orientation

kCCTransitionOrientationLeftOver  = TransitionScene::Orientation::LEFT_OVER;

kCCTransitionOrientationRightOver = TransitionScene::Orientation::RIGHT_OVER;

kCCTransitionOrientationUpOver    = TransitionScene::Orientation::UP_OVER;

kCCTransitionOrientationDownOver  = TransitionScene::Orientation::DOWN_OVER;


//ResolutionPolicy

ResolutionPolicy

kResolutionExactFit    = ResolutionPolicy::EXACT_FIT;

kResolutionNoBorder    = ResolutionPolicy::NO_BORDER;

kResolutionShowAll     = ResolutionPolicy::SHOW_ALL;

kResolutionFixedHeight = ResolutionPolicy::FIXED_HEIGHT;

kResolutionFixedWidth  = ResolutionPolicy::FIXED_WIDTH;

kResolutionUnKnown     = ResolutionPolicy::UNKNOWN;


  2.4、其他被遗弃的类

    这些类的类名为了防止重名,所以都在前面加上了 "__" 前缀。

typedef __NotificationCenter CCNotificationCenter;

typedef __NotificationCenter NotificationCenter;

typedef __CCCallFuncND       CCCallFuncND;

typedef __CCCallFuncO        CCCallFuncO;



typedef __RGBAProtocol RGBAProtocol;

typedef __NodeRGBA     NodeRGBA;

typedef __LayerRGBA    LayerRGBA;



//将被Map、Vector替代

typedef __Set         CCSet;

typedef __Set         Set;

typedef __SetIterator CCSetIterator;

typedef __SetIterator SetIterator;

typedef __Array       CCArray;

typedef __Array       Array;

typedef __Dictionary  Dictionary;

typedef __Dictionary  CCDictionary;



//将被Value替代

typedef __Double  Double;

typedef __Double  CCDouble;

typedef __Float   Float;

typedef __Float   CCFloat;

typedef __Integer Integer;

typedef __Integer CCInteger;

typedef __Bool    Bool;

typedef __Bool    CCBool;

typedef __String  CCString;

typedef __String  String;



推荐阅读:
  1. ASP.NET Core消息队列RabbitMQ基础入门实战演练
  2. .NET和Python哪个好?新应用诞生.NET依赖注入在区块链项目AElf中的实践问题

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

cocos2dx 3.x %pre

上一篇:hadoop1.x   MapReduce工作原理

下一篇:Go语言开发(四)、Go语言面向对象

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》