资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

cocos2dx[3.2](4)——浅析CCDeprecated.h-创新互联

【唠叨】

网站设计制作、网站制作过程中,需要针对客户的行业特点、产品特性、目标受众和市场情况进行定位分析,以确定网站的风格、色彩、版式、交互等方面的设计方向。成都创新互联还需要根据客户的需求进行功能模块的开发和设计,包括内容管理、前台展示、用户权限管理、数据统计和安全保护等功能。

    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;

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


网页标题:cocos2dx[3.2](4)——浅析CCDeprecated.h-创新互联
路径分享:http://cdkjz.cn/article/gsspo.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220