mirror of https://github.com/axmolengine/axmol.git
closed #3162: add RGBAProtocol, NodeRGBA and LayerRGBA back and deprecate them
This commit is contained in:
parent
0e94d4f3b8
commit
d6d7923134
|
@ -571,6 +571,8 @@ CC_DEPRECATED_ATTRIBUTE typedef Touch CCTouch;
|
|||
CC_DEPRECATED_ATTRIBUTE typedef Set CCSet;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef Texture2D CCTexture2D;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef Node CCNode;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef Node CCNodeRGBA;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef Node CCRGBAProtocol;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef SpriteFrame CCSpriteFrame;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef AnimationFrame CCAnimationFrame;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef Animation CCAnimation;
|
||||
|
@ -687,6 +689,7 @@ CC_DEPRECATED_ATTRIBUTE typedef SpriteBatchNode CCSpriteBatchNode;
|
|||
CC_DEPRECATED_ATTRIBUTE typedef LabelBMFont CCLabelBMFont;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef Layer CCLayer;
|
||||
//CC_DEPRECATED_ATTRIBUTE typedef KeypadDelegate CCKeypadDelegate;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef Layer CCLayerRGBA;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef LayerColor CCLayerColor;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef LayerGradient CCLayerGradient;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef LayerMultiplex CCLayerMultiplex;
|
||||
|
|
|
@ -184,6 +184,48 @@ private:
|
|||
|
||||
};
|
||||
|
||||
|
||||
/** LayerRGBA is a subclass of Layer that implements the RGBAProtocol protocol using a solid color as the background.
|
||||
|
||||
All features from Layer are valid, plus the following new features that propagate into children that conform to the RGBAProtocol:
|
||||
- opacity
|
||||
- RGB colors
|
||||
@since 2.1
|
||||
*/
|
||||
class CC_DLL CC_DEPRECATED_ATTRIBUTE LayerRGBA : public Layer, public RGBAProtocol
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(LayerRGBA);
|
||||
|
||||
|
||||
//
|
||||
// Overrides
|
||||
//
|
||||
virtual GLubyte getOpacity() const override { return Layer::getOpacity(); }
|
||||
virtual GLubyte getDisplayedOpacity() const override { return Layer::getDisplayedOpacity(); }
|
||||
virtual void setOpacity(GLubyte opacity) override { return Layer::setOpacity(opacity); }
|
||||
virtual void updateDisplayedOpacity(GLubyte parentOpacity) override { return Layer::updateDisplayedOpacity(parentOpacity); }
|
||||
virtual bool isCascadeOpacityEnabled() const override { return Layer::isCascadeOpacityEnabled(); }
|
||||
virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled) override { return Layer::setCascadeOpacityEnabled(cascadeOpacityEnabled); }
|
||||
|
||||
virtual const Color3B& getColor() const override { return Layer::getColor(); }
|
||||
virtual const Color3B& getDisplayedColor() const override { return Layer::getDisplayedColor(); }
|
||||
virtual void setColor(const Color3B& color) override { return Layer::setColor(color); }
|
||||
virtual void updateDisplayedColor(const Color3B& parentColor) override { return Layer::updateDisplayedColor(parentColor); }
|
||||
virtual bool isCascadeColorEnabled() const override { return Layer::isCascadeOpacityEnabled(); }
|
||||
virtual void setCascadeColorEnabled(bool cascadeColorEnabled) override { return Layer::setCascadeColorEnabled(cascadeColorEnabled); }
|
||||
|
||||
virtual void setOpacityModifyRGB(bool bValue) override { return Layer::setOpacityModifyRGB(bValue); }
|
||||
virtual bool isOpacityModifyRGB() const override { return Layer::isOpacityModifyRGB(); }
|
||||
|
||||
protected:
|
||||
LayerRGBA() {}
|
||||
virtual ~LayerRGBA() {}
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(LayerRGBA);
|
||||
};
|
||||
|
||||
//
|
||||
// LayerColor
|
||||
//
|
||||
|
|
|
@ -1512,6 +1512,46 @@ private:
|
|||
CC_DISALLOW_COPY_AND_ASSIGN(Node);
|
||||
};
|
||||
|
||||
//#pragma mark - NodeRGBA
|
||||
|
||||
/** NodeRGBA is a subclass of Node that implements the RGBAProtocol protocol.
|
||||
|
||||
All features from Node are valid, plus the following new features:
|
||||
- opacity
|
||||
- RGB colors
|
||||
|
||||
Opacity/Color propagates into children that conform to the RGBAProtocol if cascadeOpacity/cascadeColor is enabled.
|
||||
@since v2.1
|
||||
*/
|
||||
class CC_DLL CC_DEPRECATED_ATTRIBUTE NodeRGBA : public Node, public RGBAProtocol
|
||||
{
|
||||
public:
|
||||
// overrides
|
||||
virtual GLubyte getOpacity() const override { return Node::getOpacity(); }
|
||||
virtual GLubyte getDisplayedOpacity() const override { return Node::getDisplayedOpacity(); }
|
||||
virtual void setOpacity(GLubyte opacity) override { return Node::setOpacity(opacity); }
|
||||
virtual void updateDisplayedOpacity(GLubyte parentOpacity) override { return Node::updateDisplayedOpacity(parentOpacity); }
|
||||
virtual bool isCascadeOpacityEnabled() const override { return Node::isCascadeOpacityEnabled(); }
|
||||
virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled) override { return Node::setCascadeOpacityEnabled(cascadeOpacityEnabled); }
|
||||
|
||||
virtual const Color3B& getColor(void) const override { return Node::getColor(); }
|
||||
virtual const Color3B& getDisplayedColor() const override { return Node::getDisplayedColor(); }
|
||||
virtual void setColor(const Color3B& color) override { return Node::setColor(color); }
|
||||
virtual void updateDisplayedColor(const Color3B& parentColor) override { return Node::updateDisplayedColor(parentColor); }
|
||||
virtual bool isCascadeColorEnabled() const override { return Node::isCascadeColorEnabled(); }
|
||||
virtual void setCascadeColorEnabled(bool cascadeColorEnabled) override { return Node::setCascadeColorEnabled(cascadeColorEnabled); }
|
||||
|
||||
virtual void setOpacityModifyRGB(bool bValue) override { return Node::setOpacityModifyRGB(bValue); }
|
||||
virtual bool isOpacityModifyRGB() const override { return Node::isOpacityModifyRGB(); }
|
||||
|
||||
protected:
|
||||
NodeRGBA() {}
|
||||
virtual ~NodeRGBA() {}
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(NodeRGBA);
|
||||
};
|
||||
|
||||
// end of base_node group
|
||||
/// @}
|
||||
|
||||
|
|
|
@ -32,6 +32,133 @@ THE SOFTWARE.
|
|||
|
||||
NS_CC_BEGIN
|
||||
|
||||
/**
|
||||
* RGBA protocol that affects Node's color and opacity
|
||||
*/
|
||||
class CC_DLL CC_DEPRECATED_ATTRIBUTE RGBAProtocol
|
||||
{
|
||||
public:
|
||||
virtual ~RGBAProtocol() {}
|
||||
|
||||
/**
|
||||
* Changes the color with R,G,B bytes
|
||||
*
|
||||
* @param color Example: Color3B(255,100,0) means R=255, G=100, B=0
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void setColor(const Color3B& color) = 0;
|
||||
|
||||
/**
|
||||
* Returns color that is currently used.
|
||||
*
|
||||
* @return The Color3B contains R,G,B bytes.
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual const Color3B& getColor() const = 0;
|
||||
|
||||
/**
|
||||
* Returns the displayed color.
|
||||
*
|
||||
* @return The Color3B contains R,G,B bytes.
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual const Color3B& getDisplayedColor() const = 0;
|
||||
|
||||
/**
|
||||
* Returns the displayed opacity.
|
||||
*
|
||||
* @return The opacity of sprite, from 0 ~ 255
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual GLubyte getDisplayedOpacity() const = 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
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual GLubyte getOpacity() const = 0;
|
||||
|
||||
/**
|
||||
* Changes the opacity.
|
||||
*
|
||||
* @param opacity Goes from 0 to 255, where 255 means fully opaque and 0 means fully transparent.
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
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 value If true, then the opacity will be applied as: glColor(R,G,B,opacity);
|
||||
* If false, then the opacity will be applied as: glColor(opacity, opacity, opacity, opacity);
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void setOpacityModifyRGB(bool value) = 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.
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual bool isOpacityModifyRGB() const = 0;
|
||||
|
||||
/**
|
||||
* whether or not color should be propagated to its children.
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual bool isCascadeColorEnabled() const = 0;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void setCascadeColorEnabled(bool cascadeColorEnabled) = 0;
|
||||
|
||||
/**
|
||||
* recursive method that updates display color
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void updateDisplayedColor(const Color3B& color) = 0;
|
||||
|
||||
/**
|
||||
* whether or not opacity should be propagated to its children.
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual bool isCascadeOpacityEnabled() const = 0;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled) = 0;
|
||||
|
||||
/**
|
||||
* recursive method that updates the displayed opacity.
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void updateDisplayedOpacity(GLubyte opacity) = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Specify the blending function according glBlendFunc
|
||||
* Please refer to glBlendFunc in OpenGL ES Manual
|
||||
|
|
|
@ -271,6 +271,14 @@ end
|
|||
_G["CCFadeIn"] = DeprecatedClass.CCFadeIn()
|
||||
--CCFadeIn class will be Deprecated,end
|
||||
|
||||
--CCNodeRGBA class will be Deprecated,begin
|
||||
function DeprecatedClass.CCNodeRGBA()
|
||||
deprecatedTip("CCNodeRGBA","cc.Node")
|
||||
return cc.Node
|
||||
end
|
||||
_G["CCNodeRGBA"] = DeprecatedClass.CCNodeRGBA()
|
||||
--CCNodeRGBA class will be Deprecated,end
|
||||
|
||||
--CCAnimationCache class will be Deprecated,begin
|
||||
function DeprecatedClass.CCAnimationCache()
|
||||
deprecatedTip("CCAnimationCache","cc.AnimationCache")
|
||||
|
@ -1295,6 +1303,14 @@ end
|
|||
_G["CCCamera"] = DeprecatedClass.CCCamera()
|
||||
--CCCamera class will be Deprecated,end
|
||||
|
||||
--CCLayerRGBA class will be Deprecated,begin
|
||||
function DeprecatedClass.CCLayerRGBA()
|
||||
deprecatedTip("CCLayerRGBA","cc.Layer")
|
||||
return cc.Layer
|
||||
end
|
||||
_G["CCLayerRGBA"] = DeprecatedClass.CCLayerRGBA()
|
||||
--CCLayerRGBA class will be Deprecated,end
|
||||
|
||||
--CCBezierTo class will be Deprecated,begin
|
||||
function DeprecatedClass.CCBezierTo()
|
||||
deprecatedTip("CCBezierTo","cc.BezierTo")
|
||||
|
|
Loading…
Reference in New Issue