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

相关文章

MySQL 中的 CAST 函数详解及常见用法

《MySQL中的CAST函数详解及常见用法》CAST函数是MySQL中用于数据类型转换的重要函数,它允许你将一个值从一种数据类型转换为另一种数据类型,本文给大家介绍MySQL中的CAST... 目录mysql 中的 CAST 函数详解一、基本语法二、支持的数据类型三、常见用法示例1. 字符串转数字2. 数字

Python内置函数之classmethod函数使用详解

《Python内置函数之classmethod函数使用详解》:本文主要介绍Python内置函数之classmethod函数使用方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地... 目录1. 类方法定义与基本语法2. 类方法 vs 实例方法 vs 静态方法3. 核心特性与用法(1编程客

Python函数作用域示例详解

《Python函数作用域示例详解》本文介绍了Python中的LEGB作用域规则,详细解析了变量查找的四个层级,通过具体代码示例,展示了各层级的变量访问规则和特性,对python函数作用域相关知识感兴趣... 目录一、LEGB 规则二、作用域实例2.1 局部作用域(Local)2.2 闭包作用域(Enclos

MySQL count()聚合函数详解

《MySQLcount()聚合函数详解》MySQL中的COUNT()函数,它是SQL中最常用的聚合函数之一,用于计算表中符合特定条件的行数,本文给大家介绍MySQLcount()聚合函数,感兴趣的朋... 目录核心功能语法形式重要特性与行为如何选择使用哪种形式?总结深入剖析一下 mysql 中的 COUNT

MySQL 中 ROW_NUMBER() 函数最佳实践

《MySQL中ROW_NUMBER()函数最佳实践》MySQL中ROW_NUMBER()函数,作为窗口函数为每行分配唯一连续序号,区别于RANK()和DENSE_RANK(),特别适合分页、去重... 目录mysql 中 ROW_NUMBER() 函数详解一、基础语法二、核心特点三、典型应用场景1. 数据分

如何在Spring Boot项目中集成MQTT协议

《如何在SpringBoot项目中集成MQTT协议》本文介绍在SpringBoot中集成MQTT的步骤,包括安装Broker、添加EclipsePaho依赖、配置连接参数、实现消息发布订阅、测试接口... 目录1. 准备工作2. 引入依赖3. 配置MQTT连接4. 创建MQTT配置类5. 实现消息发布与订阅

MySQL数据库的内嵌函数和联合查询实例代码

《MySQL数据库的内嵌函数和联合查询实例代码》联合查询是一种将多个查询结果组合在一起的方法,通常使用UNION、UNIONALL、INTERSECT和EXCEPT关键字,下面:本文主要介绍MyS... 目录一.数据库的内嵌函数1.1聚合函数COUNT([DISTINCT] expr)SUM([DISTIN

Python get()函数用法案例详解

《Pythonget()函数用法案例详解》在Python中,get()是字典(dict)类型的内置方法,用于安全地获取字典中指定键对应的值,它的核心作用是避免因访问不存在的键而引发KeyError错... 目录简介基本语法一、用法二、案例:安全访问未知键三、案例:配置参数默认值简介python是一种高级编

python 常见数学公式函数使用详解(最新推荐)

《python常见数学公式函数使用详解(最新推荐)》文章介绍了Python的数学计算工具,涵盖内置函数、math/cmath标准库及numpy/scipy/sympy第三方库,支持从基础算术到复杂数... 目录python 数学公式与函数大全1. 基本数学运算1.1 算术运算1.2 分数与小数2. 数学函数

使用Python进行GRPC和Dubbo协议的高级测试

《使用Python进行GRPC和Dubbo协议的高级测试》GRPC(GoogleRemoteProcedureCall)是一种高性能、开源的远程过程调用(RPC)框架,Dubbo是一种高性能的分布式服... 目录01 GRPC测试安装gRPC编写.proto文件实现服务02 Dubbo测试1. 安装Dubb