cocos2d-x节点(ccTypes.h)API

来源:互联网 发布:whatsapp数据迁移 编辑:程序博客网 时间:2024/05/22 02:24

本文来自http://blog.csdn.net/runaying ,引用必须注明出处!

cocos2d-x节点(ccTypes.h)API

温馨提醒:为了大家能更好学习,强烈推荐大家看看本人的这篇博客 Cocos2d-X权威指南笔记

字体属性、texture属性、RGB组成......

///cocos2d-x-3.0alpha0/cocos2dx/include//字体属性、texture属性、RGB组成......#ifndef __CCTYPES_H__#define __CCTYPES_H__#include <string>#include "cocoa/CCGeometry.h"#include "CCGL.h"NS_CC_BEGIN/** RGB颜色组成的字节3字节@since v3.0 */struct Color3B{    Color3B(): r(0), g(0), b(0) {}        Color3B(GLubyte _r, GLubyte _g, GLubyte _b)        : r(_r)        , g(_g)        , b(_b)    {}        bool equals(const Color3B &other)    {        return (this->r == other.r &&                this->g == other.g &&                this->b == other.b);    }        GLubyte r;    GLubyte g;    GLubyte b;        const static Color3B WHITE;    const static Color3B YELLOW;    const static Color3B BLUE;    const static Color3B GREEN;    const static Color3B RED;    const static Color3B MAGENTA;    const static Color3B BLACK;    const static Color3B ORANGE;    const static Color3B GRAY;};struct Color4F;/** 组成 RGBA 颜色(4 字节)@since v3.0*/struct Color4B{    Color4B(GLubyte _r, GLubyte _g, GLubyte _b, GLubyte _a)        : r(_r)        , g(_g)        , b(_b)        , a(_a)    {}        Color4B(): r(0), g(0), b(0), a(0) {}        // 此功能应该使用 Color4F, so implement it in .cpp file.    explicit Color4B(const Color4F &color4F);    GLubyte r;    GLubyte g;    GLubyte b;    GLubyte a;    const static Color4B WHITE;    const static Color4B YELLOW;    const static Color4B BLUE;    const static Color4B GREEN;    const static Color4B RED;    const static Color4B MAGENTA;    const static Color4B BLACK;    const static Color4B ORANGE;    const static Color4B GRAY;};/** RGBA color 由 4 floats 组成@since v3.0*/struct Color4F{    Color4F(float _r, float _g, float _b, float _a)        : r(_r)        , g(_g)        , b(_b)        , a(_a)    {}        explicit Color4F(const Color3B &color3B)        : r(color3B.r / 255.0f)        , g(color3B.g / 255.0f)        , b(color3B.b / 255.0f)        , a(1.f)    {}        explicit Color4F(const Color4B &color4B)        : r(color4B.r / 255.0f)        , g(color4B.g / 255.0f)        , b(color4B.b / 255.0f)        , a(color4B.a / 255.0f)    {}        Color4F(): r(0.f), g(0.f), b(0.f), a(0.f) {}        bool equals(const Color4F &other)    {        return (this->r == other.r &&                this->g == other.g &&                this->b == other.b &&                this->a == other.a);    }        GLfloat r;    GLfloat g;    GLfloat b;    GLfloat a;    const static Color4F WHITE;    const static Color4F YELLOW;    const static Color4F BLUE;    const static Color4F GREEN;    const static Color4F RED;    const static Color4F MAGENTA;    const static Color4F BLACK;    const static Color4F ORANGE;    const static Color4F GRAY;};/** A vertex 由 2 floats 组成: x, y @since v3.0 */struct Vertex2F{    Vertex2F(float _x, float _y) :x(_x), y(_y) {}        Vertex2F(): x(0.f), y(0.f) {}        GLfloat x;    GLfloat y;};/** A vertex 由 2 floats 组成: x, y @since v3.0 */struct Vertex3F{    Vertex3F(float _x, float _y, float _z)        : x(_x)        , y(_y)        , z(_z)    {}        Vertex3F(): x(0.f), y(0.f), z(0.f) {}        GLfloat x;    GLfloat y;    GLfloat z;};        /** A texcoord(textureCoord 纹理坐标) composed(组成) of 2 floats: u, y @since v3.0 */struct Tex2F {    Tex2F(float _u, float _v): u(_u), v(_v) {}        Tex2F(): u(0.f), v(0.f) {}        GLfloat u;    GLfloat v;}; //! Point Sprite component(组件)struct PointSprite{    Vertex2F   pos;        // 8 bytes    Color4B    color;      // 4 bytes    GLfloat    size;       // 4 bytes};//!    A 2D Quad. 4 * 2 floats      //四struct Quad2{    Vertex2F        tl;    Vertex2F        tr;    Vertex2F        bl;    Vertex2F        br;};//!    A 3D Quad. 4 * 3 floats      //四struct Quad3 {    Vertex3F        bl;    Vertex3F        br;    Vertex3F        tl;    Vertex3F        tr;};//备注 :texcoord 是纹理坐标,在后续的Pixel shader中会用到用来读取纹理颜色//! 一个顶点, a tex coord point(纹理坐标) and a color 4B   //顶点struct V2F_C4B_T2F{    //! vertices (2F)               //顶点    Vertex2F       vertices;    //! colors (4B)    Color4B        colors;    //! tex coords (2F)    Tex2F          texCoords;};//! 一个顶点, a tex coord point(纹理坐标) and a color 4F       //顶点struct V2F_C4F_T2F{    //! vertices (2F)       //顶点    Vertex2F       vertices;    //! colors (4F)    Color4F        colors;    //! tex coords (2F)    Tex2F          texCoords;};//! 一个顶点, a tex coord point(纹理坐标) and a color 4B   //顶点struct V3F_C4B_T2F{    //! vertices (3F)               //顶点    Vertex3F     vertices;            // 12 bytes    //! colors (4B)    Color4B      colors;              // 4 bytes    // tex coords (2F)    Tex2F        texCoords;           // 8 bytes};//! A Triangle of V2F_C4B_T2F           //三角形struct V2F_C4B_T2F_Triangle{//! Point AV2F_C4B_T2F a;//! Point BV2F_C4B_T2F b;//! Point BV2F_C4B_T2F c;};//! A Quad of V2F_C4B_T2Fstruct V2F_C4B_T2F_Quad{    //! bottom left             //下    V2F_C4B_T2F    bl;    //! bottom right            //下    V2F_C4B_T2F    br;    //! top left    V2F_C4B_T2F    tl;    //! top right    V2F_C4B_T2F    tr;};//! 4 Vertex3FTex2FColor4Bstruct V3F_C4B_T2F_Quad{    //! top left    V3F_C4B_T2F    tl;    //! bottom left           //下    V3F_C4B_T2F    bl;    //! top right    V3F_C4B_T2F    tr;    //! bottom right    V3F_C4B_T2F    br;};//! 4 Vertex2FTex2FColor4F Quadstruct V2F_C4F_T2F_Quad{    //! bottom left           //下    V2F_C4F_T2F    bl;    //! bottom right           //下    V2F_C4F_T2F    br;    //! top left    V2F_C4F_T2F    tl;    //! top right    V2F_C4F_T2F    tr;};//!  textures 使用的混合函数struct BlendFunc{    //! source blend function           //源混合功能    GLenum src;    //! destination blend function      //目标混合功能    GLenum dst;    //! Blending(混合) disabled. Uses {GL_ONE, GL_ZERO}    const static BlendFunc DISABLE;    //! Blending(混合) enabled for textures with Alpha premultiplied(预乘). Uses {GL_ONE, GL_ONE_MINUS_SRC_ALPHA}    const static BlendFunc ALPHA_PREMULTIPLIED;    //! Blending(混合) enabled for textures with Alpha NON(非) premultiplied(预乘). Uses {GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA}    const static BlendFunc ALPHA_NON_PREMULTIPLIED;    //! Enables Additive(附加) blending(混合). Uses {GL_SRC_ALPHA, GL_ONE}    const static BlendFunc ADDITIVE;};// Label::VAlignment        //对齐// Label::HAlignment// XXX: 如果这些枚举被编辑, and/or 重新排序, 都会更新 Texture2D.m//! Vertical text alignment type                //垂直enum class TextVAlignment{    TOP,    CENTER,    BOTTOM,};// XXX: 如果这些枚举被编辑, and/or 重新排序, 都会更新 Texture2D.m//! Horizontal text alignment type              //水平enum class TextHAlignment{    LEFT,    CENTER,    RIGHT,};// animation 中的粒子系统的类型// texture coordinates(坐标)for a quad        //四struct T2F_Quad{    //! bottom left             //下    Tex2F    bl;    //! bottom right            //下    Tex2F    br;    //! top left    Tex2F    tl;    //! top right    Tex2F    tr;};// ParticleSystemQuad 动画的 延迟、texture 坐标、持有尺寸(以像素为单位)struct AnimationFrameData{    T2F_Quad texCoords;    float delay;    Size size; };/** 定义的字体属性类型 (i.e. font name, size, stroke(笔画样式)or 阴影) */// 阴影属性struct FontShadow{public:        // 默认情况下,不启用阴影    FontShadow()        : _shadowEnabled(false)        , _shadowBlur(0)        , _shadowOpacity(0)    {}    // true 启用阴影    bool   _shadowEnabled;    // 阴影偏移(x,y)Size   _shadowOffset;    // 模糊阴影float  _shadowBlur;    // 阴影透明度float  _shadowOpacity;};// stroke(描边)属性struct FontStroke{public:        // 默认情况下禁止 stroke    FontStroke()    : _strokeEnabled(false)        , _strokeColor(Color3B::BLACK)        , _strokeSize(0)    {}        // true if stroke enabled    bool      _strokeEnabled;    // stroke colorColor3B   _strokeColor;    // stroke size    float     _strokeSize;    };// font attributesstruct FontDefinition{public:    /**     * @js NA     * @lua NA     */    FontDefinition()        : _fontSize(0)        , _alignment(TextHAlignment::CENTER)        , _vertAlignment(TextVAlignment::TOP)    , _dimensions(Size::ZERO)        , _fontFillColor(Color3B::WHITE)    {}        // font name    std::string           _fontName;    // font size    int                   _fontSize;    // horizontal alignment                 //水平对齐    TextHAlignment        _alignment;    // vertical alignment                      //垂直对齐    TextVAlignment _vertAlignment;    // renering(渲染) box    Size                  _dimensions;    // font color    Color3B               _fontFillColor;    // font shadow    FontShadow            _shadow;    // font stroke    FontStroke            _stroke;    };/** @brief 设备的加速的报告,每个单元轴 g-force(力的大小) */class Acceleration{public:    double x;    double y;    double z;        double timestamp;        Acceleration(): x(0), y(0), z(0), timestamp(0) {}};NS_CC_END#endif //__CCTYPES_H__


原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 小孩米粉吃多了怎么办 宝宝四个月了奶水不足怎么办 4个月奶水不足怎么办 孩子不吃奶粉母乳又不够怎么办 宝宝吃母乳上火了怎么办 5个月宝宝厌奶期怎么办 九个月宝宝不吃奶粉怎么办 第5个月奶不够吃怎么办 九个月的宝宝不吃奶粉怎么办 9个月宝宝不肯吃怎么办 11个月不吃辅食怎么办 4个月母乳不足怎么办 宝宝四个月奶不够怎么办 四个月宝宝奶不够吃怎么办 宝宝吃母乳偏瘦怎么办 宝宝吃母乳很瘦怎么办 8个月宝宝流汗太多怎么办 奶水多乳房胀疼怎么办 乳房胀奶奶水减少怎么办 宝宝五个月奶水不够吃怎么办 梦见鬼在梦里怎么办 宝宝晚上奶水不够吃怎么办 十个月晚上奶水不够吃怎么办 产妇晚上奶水不够吃怎么办 刚出生的宝宝不吃母乳怎么办 宝宝六个月奶不够吃怎么办 六个月奶不够吃怎么办 刚出生奶不够吃怎么办 做梦醒了看见鬼怎么办 宝宝到陌生地方哭闹怎么办 大人生病住院小孩没人带怎么办 孕妇被小猫抓了怎么办 怀孕了家里有猫怎么办 厕所被湿纸巾堵了怎么办 5天新生儿不拉屎怎么办 4月宝宝不拉屎怎么办 两岁宝宝晚上睡觉哭闹怎么办 2月婴儿吐奶很多怎么办 心情不好回奶了怎么办 四个月了没奶怎么办 八岁宝宝还尿床怎么办