本文隶属于专题系列: cocos2dx 3.x系列

【唠叨】

    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;

你可能感兴趣的内容
0条评论

dexcoder

这家伙太懒了 <( ̄ ﹌  ̄)>
Owner