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

相关文章

vue, 左右布局宽,可拖动改变

1:建立一个draggableMixin.js  混入的方式使用 2:代码如下draggableMixin.js  export default {data() {return {leftWidth: 330,isDragging: false,startX: 0,startWidth: 0,};},methods: {startDragging(e) {this.isDragging = tr

【操作系统】信号Signal超详解|捕捉函数

🔥博客主页: 我要成为C++领域大神🎥系列专栏:【C++核心编程】 【计算机网络】 【Linux编程】 【操作系统】 ❤️感谢大家点赞👍收藏⭐评论✍️ 本博客致力于知识分享,与更多的人进行学习交流 ​ 如何触发信号 信号是Linux下的经典技术,一般操作系统利用信号杀死违规进程,典型进程干预手段,信号除了杀死进程外也可以挂起进程 kill -l 查看系统支持的信号

JavaScript全屏,监听页面是否全屏

在JavaScript中,直接监听浏览器是否进入全屏模式并不直接支持,因为全屏API主要是关于请求和退出全屏模式的,而没有直接的监听器可以告知页面何时进入或退出全屏模式。但是,你可以通过在你的代码中跟踪全屏状态的改变来模拟这个功能。 以下是一个基本的示例,展示了如何使用全屏API来请求全屏模式,并在请求成功或失败时更新一个状态变量: javascriptlet isInFullscreen =

java中查看函数运行时间和cpu运行时间

android开发调查性能问题中有一个现象,函数的运行时间远低于cpu执行时间,因为函数运行期间线程可能包含等待操作。native层可以查看实际的cpu执行时间和函数执行时间。在java中如何实现? 借助AI得到了答案 import java.lang.management.ManagementFactory;import java.lang.management.Threa

探索蓝牙协议的奥秘:用ESP32实现高质量蓝牙音频传输

蓝牙(Bluetooth)是一种短距离无线通信技术,广泛应用于各种电子设备之间的数据传输。自1994年由爱立信公司首次提出以来,蓝牙技术已经经历了多个版本的更新和改进。本文将详细介绍蓝牙协议,并通过一个具体的项目——使用ESP32实现蓝牙音频传输,来展示蓝牙协议的实际应用及其优点。 蓝牙协议概述 蓝牙协议栈 蓝牙协议栈是蓝牙技术的核心,定义了蓝牙设备之间如何进行通信。蓝牙协议

SQL Server中,isnull()函数以及null的用法

SQL Serve中的isnull()函数:          isnull(value1,value2)         1、value1与value2的数据类型必须一致。         2、如果value1的值不为null,结果返回value1。         3、如果value1为null,结果返回vaule2的值。vaule2是你设定的值。        如

智能客服到个人助理,国内AI大模型如何改变我们的生活?

引言 随着人工智能(AI)技术的高速发展,AI大模型越来越多地出现在我们的日常生活和工作中。国内的AI大模型在过去几年里取得了显著的进展,不少独创的技术点和实际应用令人瞩目。 那么,国内的AI大模型有哪些独创的技术点?它们在实际应用中又有哪些出色表现呢?此外,普通人又该如何利用这些大模型提升工作和生活的质量和效率呢?本文将为你一一解析。 一、国内AI大模型的独创技术点 多模态学习 多

tf.split()函数解析

API原型(TensorFlow 1.8.0): tf.split(     value,     num_or_size_splits,     axis=0,     num=None,     name='split' ) 这个函数是用来切割张量的。输入切割的张量和参数,返回切割的结果。  value传入的就是需要切割的张量。  这个函数有两种切割的方式: 以三个维度的张量为例,比如说一

【杂记-浅谈DHCP动态主机配置协议】

DHCP动态主机配置协议 一、DHCP概述1、定义2、作用3、报文类型 二、DHCP的工作原理三、DHCP服务器的配置和管理 一、DHCP概述 1、定义 DHCP,Dynamic Host Configuration Protocol,动态主机配置协议,是一种网络协议,主要用于在IP网络中自动分配和管理IP地址以及其他网络配置参数。 2、作用 DHCP允许计算机和其他设备通

神经网络第三篇:输出层及softmax函数

在上一篇专题中,我们以三层神经网络的实现为例,介绍了如何利用Python和Numpy编程实现神经网络的计算。其中,中间(隐藏)层和输出层的激活函数分别选择了 sigmoid函数和恒等函数。此刻,我们心中不难发问:为什么要花一个专题来介绍输出层及其激活函数?它和中间层又有什么区别?softmax函数何来何去?下面我们带着这些疑问进入本专题的知识点: 1 输出层概述 2 回归问题及恒等函数 3