diff --git a/cocos2dx/include/CCProtocols.h b/cocos2dx/include/CCProtocols.h index 7fd60d3208..d34768f7ae 100644 --- a/cocos2dx/include/CCProtocols.h +++ b/cocos2dx/include/CCProtocols.h @@ -55,7 +55,7 @@ public: /** * Returns the opacity. * - * The opacity which indicates how transparent or opaque this sprite is. + * 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 @@ -65,8 +65,6 @@ public: /** * Changes the opacity. * - * @warning If the the sprite's texture has premultiplied alpha then, the R, G and B channels will be modified. - * * @param value Goes from 0 to 255, where 255 means fully opaque and 0 means fully transparent. */ virtual void setOpacity(GLubyte opacity) = 0; @@ -74,13 +72,12 @@ public: // optional /** - * Changes the premultipliedAlphaOpacity property. + * 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. * - * Textures with premultiplied alpha will have this property by default on YES. - * Otherwise the default value is NO. - * - * @param bValue If set to NO then opacity will be applied as: glColor(R,G,B,opacity); - * If set to YES then opacity will be applied as: glColor(opacity, opacity, opacity, opacity); + * @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; @@ -102,7 +99,7 @@ class CC_DLL CCBlendProtocol { public: /** - * Sets the source blending function for the texture. + * 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}. @@ -111,7 +108,7 @@ public: virtual void setBlendFunc(ccBlendFunc blendFunc) = 0; /** - * Returns the blending function that is currently being used for the texture. + * Returns the blending function that is currently being used. * * @return A ccBlendFunc structure with source and destination factor which specified pixel arithmetic. */ @@ -119,7 +116,7 @@ public: }; /** - * CCNode objects that uses a Texture2D to render the images. + * 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 diff --git a/cocos2dx/include/ccTypes.h b/cocos2dx/include/ccTypes.h index 07c20d175f..11a75339fd 100644 --- a/cocos2dx/include/ccTypes.h +++ b/cocos2dx/include/ccTypes.h @@ -37,8 +37,8 @@ NS_CC_BEGIN */ typedef struct _ccColor3B { - GLubyte r; - GLubyte g; + GLubyte r; + GLubyte g; GLubyte b; } ccColor3B; diff --git a/cocos2dx/sprite_nodes/CCSprite.h b/cocos2dx/sprite_nodes/CCSprite.h index 13be9c7133..0ab007b4f8 100644 --- a/cocos2dx/sprite_nodes/CCSprite.h +++ b/cocos2dx/sprite_nodes/CCSprite.h @@ -110,9 +110,8 @@ public: static CCSprite* create(const char *pszFileName, const CCRect& rect); /** - * Creates a sprite with a exsiting texture contained in CCTexture2D object - * - * After creation, the rect will be the size of the texture, and thhe offset will be (0,0). + * Creates a sprite with an exsiting texture contained in a CCTexture2D object + * After creation, the rect will be the size of the texture, and the offset will be (0,0). * * @param pTexture A pointer to a CCTexture2D object. * @return A valid sprite object that is marked as autoreleased. @@ -124,9 +123,9 @@ public: * * After creation, the offset will be (0,0). * - * @param pTexture A pointer to an exisiting CCTexture2D object. + * @param pTexture A pointer to an existing CCTexture2D object. * You can use a CCTexture2D object for many sprites. - * @param rect Only the contents inside rect of this texture will be applied for this sprite. + * @param rect Only the contents inside the rect of this texture will be applied for this sprite. * @return A valid sprite object that is marked as autoreleased. */ static CCSprite* createWithTexture(CCTexture2D *pTexture, const CCRect& rect); @@ -142,10 +141,10 @@ public: /** * Creates a sprite with an sprite frame name. * - * A CCSpriteFrame will be fetched from the CCSpriteFrameCache by name. + * A CCSpriteFrame will be fetched from the CCSpriteFrameCache by pszSpriteFrameName param. * If the CCSpriteFrame doesn't exist it will raise an exception. * - * @param pszSpriteFrameName + * @param pszSpriteFrameName A null terminated string which indicates the sprite frame name. * @return A valid sprite object that is marked as autoreleased. */ static CCSprite* createWithSpriteFrameName(const char *pszSpriteFrameName); @@ -177,7 +176,7 @@ public: * * After initialization, the rect used will be the size of the texture, and the offset will be (0,0). * - * @param pTexture A pointer to an exisiting CCTexture2D object. + * @param pTexture A pointer to an existing CCTexture2D object. * You can use a CCTexture2D object for many sprites. * @return true if the sprite is initialized properly, false otherwise. */ @@ -196,7 +195,7 @@ public: virtual bool initWithTexture(CCTexture2D *pTexture, const CCRect& rect); /** - * Initializes an sprite with a texture and a rect in points, optionally rotated. + * Initializes a sprite with a texture and a rect in points, optionally rotated. * * After initialization, the offset will be (0,0). * @note This is the designated initializer. @@ -217,7 +216,7 @@ public: virtual bool initWithSpriteFrame(CCSpriteFrame *pSpriteFrame); /** - * Initializes an sprite with an sprite frame name. + * Initializes a sprite with an sprite frame name. * * A CCSpriteFrame will be fetched from the CCSpriteFrameCache by name. * If the CCSpriteFrame doesn't exist it will raise an exception. @@ -228,7 +227,7 @@ public: virtual bool initWithSpriteFrameName(const char *pszSpriteFrameName); /** - * Initializes an sprite with an image filename. + * Initializes a sprite with an image filename. * * This method will find pszFilename from local file system, load its content to CCTexture2D, * then use CCTexture2D to create a sprite. @@ -240,7 +239,7 @@ public: virtual bool initWithFile(const char *pszFilename); /** - * Initializes an sprite with an image filename, and a rect. + * Initializes a sprite with an image filename, and a rect. * * This method will find pszFilename from local file system, load its content to CCTexture2D, * then use CCTexture2D to create a sprite. @@ -258,9 +257,25 @@ public: /// @{ /// @name Functions inherited from CCRGBAProtocol inline virtual GLubyte getOpacity() { return m_nOpacity; } + /** + * Changes the opacity. + * + * @warning If the sprite's texture has premultiplied alpha then, the R, G and B channels will be modified. + * + * @param value Goes from 0 to 255, where 255 means fully opaque and 0 means fully transparent. + */ virtual void setOpacity(GLubyte value); - virtual ccColor3B getColor(); + virtual const ccColor3B& getColor(); virtual void setColor(const ccColor3B& value); + /** + * Changes the premultipliedAlphaOpacity property. + * + * Textures with premultiplied alpha will have this property by default on true. + * Otherwise the default value is false. + * + * @param bValue flase then opacity will be applied as: glColor(R,G,B,opacity); + * true then opacity will be applied as: glColor(opacity, opacity, opacity, opacity); + */ virtual void setOpacityModifyRGB(bool bValue); virtual bool isOpacityModifyRGB(void); /// @} end of CCRGBAProtocol Inheritance @@ -303,7 +318,7 @@ public: /// @name BatchNode methods /** - * Updates the quad according the the rotation, position, scale values. + * Updates the quad according the rotation, position, scale values. */ virtual void updateTransform(void);