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

相关文章

C++统计函数执行时间的最佳实践

《C++统计函数执行时间的最佳实践》在软件开发过程中,性能分析是优化程序的重要环节,了解函数的执行时间分布对于识别性能瓶颈至关重要,本文将分享一个C++函数执行时间统计工具,希望对大家有所帮助... 目录前言工具特性核心设计1. 数据结构设计2. 单例模式管理器3. RAII自动计时使用方法基本用法高级用法

JavaScript中比较两个数组是否有相同元素(交集)的三种常用方法

《JavaScript中比较两个数组是否有相同元素(交集)的三种常用方法》:本文主要介绍JavaScript中比较两个数组是否有相同元素(交集)的三种常用方法,每种方法结合实例代码给大家介绍的非常... 目录引言:为什么"相等"判断如此重要?方法1:使用some()+includes()(适合小数组)方法2

HTTP 与 SpringBoot 参数提交与接收协议方式

《HTTP与SpringBoot参数提交与接收协议方式》HTTP参数提交方式包括URL查询、表单、JSON/XML、路径变量、头部、Cookie、GraphQL、WebSocket和SSE,依据... 目录HTTP 协议支持多种参数提交方式,主要取决于请求方法(Method)和内容类型(Content-Ty

如何通过try-catch判断数据库唯一键字段是否重复

《如何通过try-catch判断数据库唯一键字段是否重复》在MyBatis+MySQL中,通过try-catch捕获唯一约束异常可避免重复数据查询,优点是减少数据库交互、提升并发安全,缺点是异常处理开... 目录1、原理2、怎么理解“异常走的是数据库错误路径,开销比普通逻辑分支稍高”?1. 普通逻辑分支 v

GO语言中函数命名返回值的使用

《GO语言中函数命名返回值的使用》在Go语言中,函数可以为其返回值指定名称,这被称为命名返回值或命名返回参数,这种特性可以使代码更清晰,特别是在返回多个值时,感兴趣的可以了解一下... 目录基本语法函数命名返回特点代码示例命名特点基本语法func functionName(parameters) (nam

Python Counter 函数使用案例

《PythonCounter函数使用案例》Counter是collections模块中的一个类,专门用于对可迭代对象中的元素进行计数,接下来通过本文给大家介绍PythonCounter函数使用案例... 目录一、Counter函数概述二、基本使用案例(一)列表元素计数(二)字符串字符计数(三)元组计数三、C

Linux实现查看某一端口是否开放

《Linux实现查看某一端口是否开放》文章介绍了三种检查端口6379是否开放的方法:通过lsof查看进程占用,用netstat区分TCP/UDP监听状态,以及用telnet测试远程连接可达性... 目录1、使用lsof 命令来查看端口是否开放2、使用netstat 命令来查看端口是否开放3、使用telnet

Python中的filter() 函数的工作原理及应用技巧

《Python中的filter()函数的工作原理及应用技巧》Python的filter()函数用于筛选序列元素,返回迭代器,适合函数式编程,相比列表推导式,内存更优,尤其适用于大数据集,结合lamb... 目录前言一、基本概念基本语法二、使用方式1. 使用 lambda 函数2. 使用普通函数3. 使用 N

MySQL中REPLACE函数与语句举例详解

《MySQL中REPLACE函数与语句举例详解》在MySQL中REPLACE函数是一个用于处理字符串的强大工具,它的主要功能是替换字符串中的某些子字符串,:本文主要介绍MySQL中REPLACE函... 目录一、REPLACE()函数语法:参数说明:功能说明:示例:二、REPLACE INTO语句语法:参数

C# Opacity 不透明度的具体使用

《C#Opacity不透明度的具体使用》本文主要介绍了C#Opacity不透明度的具体使用,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一... 目录WinFormsOpacity以下是一些使用Opacity属性的示例:设置窗体的透明度:设置按钮的透