2010-07-06 15:46:45 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2010 cocos2d-x.org
|
|
|
|
|
2010-07-06 20:55:05 +08:00
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
2010-07-06 15:46:45 +08:00
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
|
2010-07-06 10:19:51 +08:00
|
|
|
#ifndef __CCPROTOCOLS_H__
|
|
|
|
#define __CCPROTOCOLS_H__
|
|
|
|
|
|
|
|
#include "ccTypes.h"
|
2010-07-19 16:45:53 +08:00
|
|
|
#include "CCTexture2D.h"
|
2010-08-02 11:13:36 +08:00
|
|
|
#include "ccxCommon.h"
|
2010-07-06 10:19:51 +08:00
|
|
|
|
|
|
|
#include <string>
|
2010-08-04 15:46:12 +08:00
|
|
|
namespace cocos2d {
|
2010-07-06 10:19:51 +08:00
|
|
|
|
|
|
|
// CC RGBA protocol
|
2010-08-02 11:13:36 +08:00
|
|
|
class CCX_DLL CCRGBAProtocol
|
2010-07-06 10:19:51 +08:00
|
|
|
{
|
2010-07-22 10:10:51 +08:00
|
|
|
public:
|
2010-07-06 15:46:45 +08:00
|
|
|
/** sets Color
|
|
|
|
@since v0.8
|
|
|
|
*/
|
|
|
|
virtual void setColor(ccColor3B color) = 0;
|
|
|
|
|
|
|
|
/** returns the color
|
|
|
|
@since v0.8
|
|
|
|
*/
|
2010-07-19 18:00:13 +08:00
|
|
|
virtual ccColor3B getColor(void) = 0;
|
2010-07-06 15:46:45 +08:00
|
|
|
|
|
|
|
// returns the opacity
|
2010-07-19 18:00:13 +08:00
|
|
|
virtual GLubyte getOpacity(void) = 0;
|
2010-07-06 15:46:45 +08:00
|
|
|
|
|
|
|
/** sets the opacity.
|
|
|
|
@warning If the the texture has premultiplied alpha then, the R, G and B channels will be modifed.
|
|
|
|
Values goes from 0 to 255, where 255 means fully opaque.
|
|
|
|
*/
|
|
|
|
virtual void setOpacity(GLubyte opacity) = 0;
|
|
|
|
|
|
|
|
// optional
|
|
|
|
|
|
|
|
/** sets the premultipliedAlphaOpacity property.
|
|
|
|
If set to NO then opacity will be applied as: glColor(R,G,B,opacity);
|
|
|
|
If set to YES then oapcity will be applied as: glColor(opacity, opacity, opacity, opacity );
|
|
|
|
Textures with premultiplied alpha will have this property by default on YES. Otherwise the default value is NO
|
|
|
|
@since v0.8
|
|
|
|
*/
|
2010-07-19 18:00:13 +08:00
|
|
|
virtual void setIsOpacityModifyRGB(bool bValue) {}
|
2010-07-06 15:46:45 +08:00
|
|
|
|
|
|
|
/** returns whether or not the opacity will be applied using glColor(R,G,B,opacity) or glColor(opacity, opacity, opacity, opacity);
|
|
|
|
@since v0.8
|
2010-07-06 10:19:51 +08:00
|
|
|
*/
|
2010-07-19 18:00:13 +08:00
|
|
|
virtual bool getIsOpacityModifyRGB(void) { return false;}
|
2010-07-16 14:19:55 +08:00
|
|
|
};
|
2010-07-06 10:19:51 +08:00
|
|
|
|
2010-07-06 15:46:45 +08:00
|
|
|
/**
|
|
|
|
You can specify the blending fuction.
|
|
|
|
@since v0.99.0
|
2010-07-06 10:19:51 +08:00
|
|
|
*/
|
2010-08-02 11:13:36 +08:00
|
|
|
class CCX_DLL CCBlendProtocol
|
2010-07-06 10:19:51 +08:00
|
|
|
{
|
2010-07-22 11:15:25 +08:00
|
|
|
public:
|
2010-07-06 10:19:51 +08:00
|
|
|
// set the source blending function for the texture
|
|
|
|
virtual void setBlendFunc(ccBlendFunc blendFunc) = 0;
|
|
|
|
|
|
|
|
// returns the blending function used for the texture
|
2010-07-28 15:16:00 +08:00
|
|
|
virtual ccBlendFunc getBlendFunc(void) = 0;
|
2010-07-16 14:19:55 +08:00
|
|
|
};
|
2010-07-06 10:19:51 +08:00
|
|
|
|
2010-07-06 15:46:45 +08:00
|
|
|
/** CCNode objects that uses a Texture2D 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 funtion at any time.
|
|
|
|
@since v0.8.0
|
2010-07-06 10:19:51 +08:00
|
|
|
*/
|
2010-08-02 11:13:36 +08:00
|
|
|
class CCX_DLL CCTextureProtocol : public CCBlendProtocol
|
2010-07-06 10:19:51 +08:00
|
|
|
{
|
2010-07-22 10:10:51 +08:00
|
|
|
public:
|
2010-07-06 10:19:51 +08:00
|
|
|
// returns the used texture
|
2010-07-19 18:00:13 +08:00
|
|
|
virtual CCTexture2D* getTexture(void) = 0;
|
2010-07-06 10:19:51 +08:00
|
|
|
|
|
|
|
// sets a new texture. it will be retained
|
|
|
|
virtual void setTexture(CCTexture2D *texture) {}
|
2010-07-16 14:19:55 +08:00
|
|
|
};
|
2010-07-06 10:19:51 +08:00
|
|
|
|
|
|
|
// Common interface for Labels
|
2010-08-02 11:13:36 +08:00
|
|
|
class CCX_DLL CCLabelProtocol
|
2010-07-06 10:19:51 +08:00
|
|
|
{
|
2010-07-22 10:10:51 +08:00
|
|
|
public:
|
2010-07-06 10:19:51 +08:00
|
|
|
// sets a new label using an string
|
|
|
|
virtual void setString(std::string &label) = 0;
|
|
|
|
|
|
|
|
// optional
|
2010-07-06 15:46:45 +08:00
|
|
|
/** sets a new label using a CString.
|
|
|
|
It is faster than setString since it doesn't require to alloc/retain/release an NString object.
|
|
|
|
@since v0.99.0
|
2010-07-06 10:19:51 +08:00
|
|
|
*/
|
|
|
|
virtual void setCString(char *pLabel) {}
|
2010-07-16 14:19:55 +08:00
|
|
|
};
|
2010-08-04 15:46:12 +08:00
|
|
|
}//namespace cocos2d
|
2010-07-06 10:19:51 +08:00
|
|
|
|
|
|
|
#endif // __CCPROTOCOLS_H__
|