CCProtocols(各种协议CCRGBAProtocol:函数-透明度是否改变RGB、颜色是否下传。混合协议+CCTextureProtocol+字体协议+导演协议 )

本文主要是介绍CCProtocols(各种协议CCRGBAProtocol:函数-透明度是否改变RGB、颜色是否下传。混合协议+CCTextureProtocol+字体协议+导演协议 ),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!


#ifndef __CCPROTOCOLS_H__

#define __CCPROTOCOLS_H__


#include "ccTypes.h"

#include "textures/CCTexture2D.h"

#include <string>


NS_CC_BEGIN


/**

 * RGBA protocol that affects CCNode's color and opacity   //RGBA协议 影响到节点的颜色和透明度 

 */

class CC_DLL CCRGBAProtocol //RGBA协议 包含了大量接口(需要继承后实现)setColor getColor getDisplayedColor Opacity setOpacityModifyRGB(bool)透明度是否改变RGB

setCascadeColorEnabled(bool cascadeColorEnabled) = 0;//颜色是否传播给子类 Cascade层叠

isCascadeOpacityEnabled


{

public:

    /** 

     * Changes the color with R,G,B bytes

     *

     * @param color Example: ccc3(255,100,0) means R=255, G=100, B=0

     */

    virtual void setColor(const ccColor3B& color) = 0;  


    /**

     * Returns color that is currently used.

     *

     * @return The ccColor3B contains R,G,B bytes.

     */

    virtual const ccColor3B& getColor(void) = 0;

    

    /**

     * Returns the displayed color.

     *

     * @return The ccColor3B contains R,G,B bytes.

     */

    virtual const ccColor3B& getDisplayedColor(void) = 0;

    

    /**

     * Returns the displayed opacity.

     *

     * @return  The opacity of sprite, from 0 ~ 255

     */

    virtual GLubyte getDisplayedOpacity(void) = 0;

    /**

     * Returns the opacity.

     *

     * The opacity which indicates how transparent or opaque this node is.

     * 0 indicates fully transparent and 255 is fully opaque.

     *

     * @return  The opacity of sprite, from 0 ~ 255

     */

    virtual GLubyte getOpacity(void) = 0;


    /**

     * Changes the opacity.

     *

     * @param   value   Goes from 0 to 255, where 255 means fully opaque and 0 means fully transparent.

     */

    virtual void setOpacity(GLubyte opacity) = 0;


    // optional


    /**

     * Changes the OpacityModifyRGB property. 

     * If thie property is set to true, then the rendered color will be affected by opacity.

     * Normally, r = r * opacity/255, g = g * opacity/255, b = b * opacity/255.

     *

     * @param   bValue  true then the opacity will be applied as: glColor(R,G,B,opacity);

     *                  false then the opacity will be applied as: glColor(opacity, opacity, opacity, opacity);

     */

    virtual void setOpacityModifyRGB(bool bValue) = 0;


    /**

     * Returns whether or not the opacity will be applied using glColor(R,G,B,opacity) 

     * or glColor(opacity, opacity, opacity, opacity)

     *

     * @return  Returns opacity modify flag.

     */

    virtual bool isOpacityModifyRGB(void) = 0;

    

    /**

     *  whether or not color should be propagated(传播) to its children.

     */

    virtual bool isCascadeColorEnabled(void) = 0; 

    virtual void setCascadeColorEnabled(bool cascadeColorEnabled) = 0;//颜色是否传播给子类

    

    /** 

     *  recursive method that updates display color 

     */

    virtual void updateDisplayedColor(const ccColor3B& color) = 0;

    

    /** 

     *  whether or not opacity should be propagated to its children.

     */

    virtual bool isCascadeOpacityEnabled(void) = 0;

    virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled) = 0;

    

    /**

     *  recursive method that updates the displayed opacity.

     */

    virtual void updateDisplayedOpacity(GLubyte opacity) = 0;

};


/**

 * Specify the blending function according glBlendFunc

 * Please refer to glBlendFunc in OpenGL ES Manual

 *http://www.khronos.org/opengles/sdk/docs/man/xhtml/glBlendFunc.xml for more details.

 */

class CC_DLL CCBlendProtocol //混合协议

{

public:

    /**

     * Sets the source blending function.

     *

     * @param blendFunc A structure with source and destination factor to specify pixel arithmetic, 

     *                  e.g. {GL_ONE, GL_ONE}, {GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA}.

     *

     */

    virtual void setBlendFunc(ccBlendFunc blendFunc) = 0;  //设置混合函数接口(来自OpenGL  glBlendFunc


    /**

     * Returns the blending function that is currently being used.

     * 

     * @return A ccBlendFunc structure with source and destination factor which specified pixel arithmetic.

     */

    virtual ccBlendFunc getBlendFunc(void) = 0; //得到混合函数接口(来自OpenGL)

};


/** 

 * CCNode objects that uses a CCTexture2D to render the images.

 * The texture can have a blending function.

 * If the texture has alpha premultiplied the default blending function is:

 *   src=GL_ONE dst= GL_ONE_MINUS_SRC_ALPHA

 * else

 *   src=GL_SRC_ALPHA dst= GL_ONE_MINUS_SRC_ALPHA

 * But you can change the blending function at any time.

 */

class CC_DLL CCTextureProtocol : public CCBlendProtocol  //纹理协议

{

public:

    /**

     * Returns the currently used texture

     *

     * @return  The texture that is currenlty being used.

     */

    virtual CCTexture2D* getTexture(void) = 0;


    /**

     * Sets a new texuture. It will be retained.

     *

     * @param   texture A valid CCTexture2D object, which will be applied to this sprite object.

     */

    virtual void setTexture(CCTexture2D *texture) = 0;

};


/**

 * Common(一般的) interface(接口) for Labels

 */

class CC_DLL CCLabelProtocol  //字体协议

{

public:

    /**

     * Sets a new label using an string

     *

     * @param A null terminated string 

     */

    virtual void setString(const char *label) = 0;


    /** 

     * Returns the string that is currently being used in this label 

     *

     * @return The string that is currently being used in this label

     */

    virtual const char* getString(void) = 0;

};


/** 

 * OpenGL projection(投影) protocol 

 */

class CC_DLL CCDirectorDelegate //导演协议

{

public:

    /** 

     * Will be called by CCDirector when the projection is updated, and "custom"(习惯) projection is used

     */

    virtual void updateProjection(void) = 0; //当投影更新时 这个方法将被调用 

};


NS_CC_END


#endif // __CCPROTOCOLS_H__


这篇关于CCProtocols(各种协议CCRGBAProtocol:函数-透明度是否改变RGB、颜色是否下传。混合协议+CCTextureProtocol+字体协议+导演协议 )的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/661565

相关文章

使用Python和OpenCV库实现实时颜色识别系统

《使用Python和OpenCV库实现实时颜色识别系统》:本文主要介绍使用Python和OpenCV库实现的实时颜色识别系统,这个系统能够通过摄像头捕捉视频流,并在视频中指定区域内识别主要颜色(红... 目录一、引言二、系统概述三、代码解析1. 导入库2. 颜色识别函数3. 主程序循环四、HSV色彩空间详解

OpenCV实现实时颜色检测的示例

《OpenCV实现实时颜色检测的示例》本文主要介绍了OpenCV实现实时颜色检测的示例,通过HSV色彩空间转换和色调范围判断实现红黄绿蓝颜色检测,包含视频捕捉、区域标记、颜色分析等功能,具有一定的参考... 目录一、引言二、系统概述三、代码解析1. 导入库2. 颜色识别函数3. 主程序循环四、HSV色彩空间

苹果macOS 26 Tahoe主题功能大升级:可定制图标/高亮文本/文件夹颜色

《苹果macOS26Tahoe主题功能大升级:可定制图标/高亮文本/文件夹颜色》在整体系统设计方面,macOS26采用了全新的玻璃质感视觉风格,应用于Dock栏、应用图标以及桌面小部件等多个界面... 科技媒体 MACRumors 昨日(6 月 13 日)发布博文,报道称在 macOS 26 Tahoe 中

Python中help()和dir()函数的使用

《Python中help()和dir()函数的使用》我们经常需要查看某个对象(如模块、类、函数等)的属性和方法,Python提供了两个内置函数help()和dir(),它们可以帮助我们快速了解代... 目录1. 引言2. help() 函数2.1 作用2.2 使用方法2.3 示例(1) 查看内置函数的帮助(

python判断文件是否存在常用的几种方式

《python判断文件是否存在常用的几种方式》在Python中我们在读写文件之前,首先要做的事情就是判断文件是否存在,否则很容易发生错误的情况,:本文主要介绍python判断文件是否存在常用的几种... 目录1. 使用 os.path.exists()2. 使用 os.path.isfile()3. 使用

C++ 函数 strftime 和时间格式示例详解

《C++函数strftime和时间格式示例详解》strftime是C/C++标准库中用于格式化日期和时间的函数,定义在ctime头文件中,它将tm结构体中的时间信息转换为指定格式的字符串,是处理... 目录C++ 函数 strftipythonme 详解一、函数原型二、功能描述三、格式字符串说明四、返回值五

CSS3中的字体及相关属性详解

《CSS3中的字体及相关属性详解》:本文主要介绍了CSS3中的字体及相关属性,详细内容请阅读本文,希望能对你有所帮助... 字体网页字体的三个来源:用户机器上安装的字体,放心使用。保存在第三方网站上的字体,例如Typekit和Google,可以link标签链接到你的页面上。保存在你自己Web服务器上的字

使用Python实现获取屏幕像素颜色值

《使用Python实现获取屏幕像素颜色值》这篇文章主要为大家详细介绍了如何使用Python实现获取屏幕像素颜色值,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 一、一个小工具,按住F10键,颜色值会跟着显示。完整代码import tkinter as tkimport pyau

Python中bisect_left 函数实现高效插入与有序列表管理

《Python中bisect_left函数实现高效插入与有序列表管理》Python的bisect_left函数通过二分查找高效定位有序列表插入位置,与bisect_right的区别在于处理重复元素时... 目录一、bisect_left 基本介绍1.1 函数定义1.2 核心功能二、bisect_left 与

java中BigDecimal里面的subtract函数介绍及实现方法

《java中BigDecimal里面的subtract函数介绍及实现方法》在Java中实现减法操作需要根据数据类型选择不同方法,主要分为数值型减法和字符串减法两种场景,本文给大家介绍java中BigD... 目录Java中BigDecimal里面的subtract函数的意思?一、数值型减法(高精度计算)1.