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__


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值