mirror of https://github.com/axmolengine/axmol.git
Merge pull request #4447 from boyu0/bug3162_opacity_incorrect
Bug #3162: Merge Node and NodeRGBA, fix opacity incorrect bug.
This commit is contained in:
commit
54dfa1bb00
|
@ -1624,10 +1624,9 @@ FadeIn* FadeIn::clone() const
|
|||
|
||||
void FadeIn::update(float time)
|
||||
{
|
||||
RGBAProtocol *pRGBAProtocol = dynamic_cast<RGBAProtocol*>(_target);
|
||||
if (pRGBAProtocol)
|
||||
if (_target)
|
||||
{
|
||||
pRGBAProtocol->setOpacity((GLubyte)(255 * time));
|
||||
_target->setOpacity((GLubyte)(255 * time));
|
||||
}
|
||||
/*_target->setOpacity((GLubyte)(255 * time));*/
|
||||
}
|
||||
|
@ -1662,10 +1661,9 @@ FadeOut* FadeOut::clone() const
|
|||
|
||||
void FadeOut::update(float time)
|
||||
{
|
||||
RGBAProtocol *pRGBAProtocol = dynamic_cast<RGBAProtocol*>(_target);
|
||||
if (pRGBAProtocol)
|
||||
if (_target)
|
||||
{
|
||||
pRGBAProtocol->setOpacity(GLubyte(255 * (1 - time)));
|
||||
_target->setOpacity(GLubyte(255 * (1 - time)));
|
||||
}
|
||||
/*_target->setOpacity(GLubyte(255 * (1 - time)));*/
|
||||
}
|
||||
|
@ -1718,20 +1716,18 @@ void FadeTo::startWithTarget(Node *target)
|
|||
{
|
||||
ActionInterval::startWithTarget(target);
|
||||
|
||||
RGBAProtocol *pRGBAProtocol = dynamic_cast<RGBAProtocol*>(target);
|
||||
if (pRGBAProtocol)
|
||||
if (target)
|
||||
{
|
||||
_fromOpacity = pRGBAProtocol->getOpacity();
|
||||
_fromOpacity = target->getOpacity();
|
||||
}
|
||||
/*_fromOpacity = target->getOpacity();*/
|
||||
}
|
||||
|
||||
void FadeTo::update(float time)
|
||||
{
|
||||
RGBAProtocol *pRGBAProtocol = dynamic_cast<RGBAProtocol*>(_target);
|
||||
if (pRGBAProtocol)
|
||||
if (_target)
|
||||
{
|
||||
pRGBAProtocol->setOpacity((GLubyte)(_fromOpacity + (_toOpacity - _fromOpacity) * time));
|
||||
_target->setOpacity((GLubyte)(_fromOpacity + (_toOpacity - _fromOpacity) * time));
|
||||
}
|
||||
/*_target->setOpacity((GLubyte)(_fromOpacity + (_toOpacity - _fromOpacity) * time));*/
|
||||
}
|
||||
|
@ -1777,20 +1773,18 @@ TintTo* TintTo::reverse() const
|
|||
void TintTo::startWithTarget(Node *target)
|
||||
{
|
||||
ActionInterval::startWithTarget(target);
|
||||
RGBAProtocol *pRGBAProtocol = dynamic_cast<RGBAProtocol*>(_target);
|
||||
if (pRGBAProtocol)
|
||||
if (_target)
|
||||
{
|
||||
_from = pRGBAProtocol->getColor();
|
||||
_from = _target->getColor();
|
||||
}
|
||||
/*_from = target->getColor();*/
|
||||
}
|
||||
|
||||
void TintTo::update(float time)
|
||||
{
|
||||
RGBAProtocol *pRGBAProtocol = dynamic_cast<RGBAProtocol*>(_target);
|
||||
if (pRGBAProtocol)
|
||||
if (_target)
|
||||
{
|
||||
pRGBAProtocol->setColor(Color3B(GLubyte(_from.r + (_to.r - _from.r) * time),
|
||||
_target->setColor(Color3B(GLubyte(_from.r + (_to.r - _from.r) * time),
|
||||
(GLubyte)(_from.g + (_to.g - _from.g) * time),
|
||||
(GLubyte)(_from.b + (_to.b - _from.b) * time)));
|
||||
}
|
||||
|
@ -1836,10 +1830,9 @@ void TintBy::startWithTarget(Node *target)
|
|||
{
|
||||
ActionInterval::startWithTarget(target);
|
||||
|
||||
RGBAProtocol *pRGBAProtocol = dynamic_cast<RGBAProtocol*>(target);
|
||||
if (pRGBAProtocol)
|
||||
if (target)
|
||||
{
|
||||
Color3B color = pRGBAProtocol->getColor();
|
||||
Color3B color = target->getColor();
|
||||
_fromR = color.r;
|
||||
_fromG = color.g;
|
||||
_fromB = color.b;
|
||||
|
@ -1848,10 +1841,9 @@ void TintBy::startWithTarget(Node *target)
|
|||
|
||||
void TintBy::update(float time)
|
||||
{
|
||||
RGBAProtocol *pRGBAProtocol = dynamic_cast<RGBAProtocol*>(_target);
|
||||
if (pRGBAProtocol)
|
||||
if (_target)
|
||||
{
|
||||
pRGBAProtocol->setColor(Color3B((GLubyte)(_fromR + _deltaR * time),
|
||||
_target->setColor(Color3B((GLubyte)(_fromR + _deltaR * time),
|
||||
(GLubyte)(_fromG + _deltaG * time),
|
||||
(GLubyte)(_fromB + _deltaB * time)));
|
||||
}
|
||||
|
|
|
@ -173,7 +173,7 @@ const Color3B& AtlasNode::getColor() const
|
|||
{
|
||||
return _colorUnmodified;
|
||||
}
|
||||
return NodeRGBA::getColor();
|
||||
return Node::getColor();
|
||||
}
|
||||
|
||||
void AtlasNode::setColor(const Color3B& color3)
|
||||
|
@ -187,12 +187,12 @@ void AtlasNode::setColor(const Color3B& color3)
|
|||
tmp.g = tmp.g * _displayedOpacity/255;
|
||||
tmp.b = tmp.b * _displayedOpacity/255;
|
||||
}
|
||||
NodeRGBA::setColor(tmp);
|
||||
Node::setColor(tmp);
|
||||
}
|
||||
|
||||
void AtlasNode::setOpacity(GLubyte opacity)
|
||||
{
|
||||
NodeRGBA::setOpacity(opacity);
|
||||
Node::setOpacity(opacity);
|
||||
|
||||
// special opacity for premultiplied textures
|
||||
if( _isOpacityModifyRGB )
|
||||
|
|
|
@ -48,7 +48,7 @@ If you are going to render a TextureAtlas consider subclassing AtlasNode (or a s
|
|||
All features from Node are valid, plus the following features:
|
||||
- opacity and RGB colors
|
||||
*/
|
||||
class CC_DLL AtlasNode : public NodeRGBA, public TextureProtocol
|
||||
class CC_DLL AtlasNode : public Node, public TextureProtocol
|
||||
{
|
||||
public:
|
||||
/** creates a AtlasNode with an Atlas file the width and height of each item and the quantity of items to render*/
|
||||
|
|
|
@ -560,8 +560,8 @@ CC_DEPRECATED_ATTRIBUTE typedef GLProgram CCGLProgram;
|
|||
CC_DEPRECATED_ATTRIBUTE typedef Touch CCTouch;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef Texture2D CCTexture2D;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef Node CCNode;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef NodeRGBA CCNodeRGBA;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef RGBAProtocol CCRGBAProtocol;
|
||||
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;
|
||||
|
@ -678,7 +678,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 LayerRGBA CCLayerRGBA;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef Layer CCLayerRGBA;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef LayerColor CCLayerColor;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef LayerGradient CCLayerGradient;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef LayerMultiplex CCLayerMultiplex;
|
||||
|
@ -1040,6 +1040,10 @@ CC_DEPRECATED_ATTRIBUTE typedef __Bool CCBool;
|
|||
CC_DEPRECATED_ATTRIBUTE typedef __String CCString;
|
||||
//CC_DEPRECATED_ATTRIBUTE typedef __String String;
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE typedef __RGBAProtocol RGBAProtocol;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef __NodeRGBA NodeRGBA;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef __LayerRGBA LayerRGBA;
|
||||
|
||||
NS_CC_END
|
||||
|
||||
|
||||
|
|
|
@ -109,12 +109,6 @@ Label::Label(FontAtlas *atlas, TextHAlignment alignment, bool useDistanceField,b
|
|||
, _originalUTF16String(0)
|
||||
, _advances(0)
|
||||
, _fontAtlas(atlas)
|
||||
, _displayedColor(Color3B::WHITE)
|
||||
, _realColor(Color3B::WHITE)
|
||||
, _cascadeColorEnabled(true)
|
||||
, _cascadeOpacityEnabled(true)
|
||||
, _displayedOpacity(255)
|
||||
, _realOpacity(255)
|
||||
, _isOpacityModifyRGB(true)
|
||||
,_useDistanceField(useDistanceField)
|
||||
,_useA8Shader(useA8Shader)
|
||||
|
@ -707,119 +701,24 @@ void Label::setOpacityModifyRGB(bool isOpacityModifyRGB)
|
|||
_isOpacityModifyRGB = isOpacityModifyRGB;
|
||||
|
||||
for(const auto& child: _children) {
|
||||
RGBAProtocol *pRGBAProtocol = dynamic_cast<RGBAProtocol*>(child);
|
||||
if (pRGBAProtocol)
|
||||
{
|
||||
pRGBAProtocol->setOpacityModifyRGB(_isOpacityModifyRGB);
|
||||
}
|
||||
child->setOpacityModifyRGB(_isOpacityModifyRGB);
|
||||
}
|
||||
|
||||
_reusedLetter->setOpacityModifyRGB(true);
|
||||
}
|
||||
|
||||
unsigned char Label::getOpacity() const
|
||||
{
|
||||
return _realOpacity;
|
||||
}
|
||||
|
||||
unsigned char Label::getDisplayedOpacity() const
|
||||
{
|
||||
return _displayedOpacity;
|
||||
}
|
||||
|
||||
void Label::setOpacity(GLubyte opacity)
|
||||
{
|
||||
_displayedOpacity = _realOpacity = opacity;
|
||||
_reusedLetter->setOpacity(opacity);
|
||||
if( _cascadeOpacityEnabled ) {
|
||||
GLubyte parentOpacity = 255;
|
||||
RGBAProtocol* pParent = dynamic_cast<RGBAProtocol*>(_parent);
|
||||
if (pParent && pParent->isCascadeOpacityEnabled())
|
||||
{
|
||||
parentOpacity = pParent->getDisplayedOpacity();
|
||||
}
|
||||
this->updateDisplayedOpacity(parentOpacity);
|
||||
}
|
||||
}
|
||||
void Label::updateDisplayedOpacity(GLubyte parentOpacity)
|
||||
{
|
||||
_displayedOpacity = _realOpacity * parentOpacity/255.0;
|
||||
|
||||
for(const auto &child: _children) {
|
||||
Sprite *item = static_cast<Sprite*>( child );
|
||||
item->updateDisplayedOpacity(_displayedOpacity);
|
||||
}
|
||||
|
||||
V3F_C4B_T2F_Quad *quads = _textureAtlas->getQuads();
|
||||
auto count = _textureAtlas->getTotalQuads();
|
||||
Color4B color4( _displayedColor.r, _displayedColor.g, _displayedColor.b, _displayedOpacity );
|
||||
if (_isOpacityModifyRGB)
|
||||
{
|
||||
color4.r *= _displayedOpacity/255.0f;
|
||||
color4.g *= _displayedOpacity/255.0f;
|
||||
color4.b *= _displayedOpacity/255.0f;
|
||||
}
|
||||
for (int index = 0; index < count; ++index)
|
||||
{
|
||||
quads[index].bl.colors = color4;
|
||||
quads[index].br.colors = color4;
|
||||
quads[index].tl.colors = color4;
|
||||
quads[index].tr.colors = color4;
|
||||
_textureAtlas->updateQuad(&quads[index], index);
|
||||
}
|
||||
}
|
||||
|
||||
bool Label::isCascadeOpacityEnabled() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void Label::setCascadeOpacityEnabled(bool cascadeOpacityEnabled)
|
||||
{
|
||||
_cascadeOpacityEnabled = cascadeOpacityEnabled;
|
||||
}
|
||||
|
||||
const Color3B& Label::getColor(void) const
|
||||
{
|
||||
return _realColor;
|
||||
}
|
||||
|
||||
const Color3B& Label::getDisplayedColor() const
|
||||
{
|
||||
return _displayedColor;
|
||||
}
|
||||
|
||||
void Label::setColor(const Color3B& color)
|
||||
{
|
||||
_displayedColor = _realColor = color;
|
||||
_reusedLetter->setColor(color);
|
||||
if( _cascadeColorEnabled )
|
||||
{
|
||||
Color3B parentColor = Color3B::WHITE;
|
||||
RGBAProtocol* pParent = dynamic_cast<RGBAProtocol*>(_parent);
|
||||
|
||||
if (pParent && pParent->isCascadeColorEnabled())
|
||||
parentColor = pParent->getDisplayedColor();
|
||||
|
||||
updateDisplayedColor(parentColor);
|
||||
}
|
||||
SpriteBatchNode::setColor(color);
|
||||
}
|
||||
|
||||
void Label::updateDisplayedColor(const Color3B& parentColor)
|
||||
void Label::updateColor()
|
||||
{
|
||||
_displayedColor.r = _realColor.r * parentColor.r/255.0;
|
||||
_displayedColor.g = _realColor.g * parentColor.g/255.0;
|
||||
_displayedColor.b = _realColor.b * parentColor.b/255.0;
|
||||
|
||||
for(const auto &child : _children) {
|
||||
Sprite *item = static_cast<Sprite*>( child );
|
||||
item->updateDisplayedColor(_displayedColor);
|
||||
}
|
||||
|
||||
V3F_C4B_T2F_Quad *quads = _textureAtlas->getQuads();
|
||||
auto count = _textureAtlas->getTotalQuads();
|
||||
Color4B color4( _displayedColor.r, _displayedColor.g, _displayedColor.b, _displayedOpacity );
|
||||
|
||||
|
||||
// special opacity for premultiplied textures
|
||||
if (_isOpacityModifyRGB)
|
||||
{
|
||||
|
@ -828,23 +727,13 @@ void Label::updateDisplayedColor(const Color3B& parentColor)
|
|||
color4.b *= _displayedOpacity/255.0f;
|
||||
}
|
||||
for (int index=0; index<count; ++index)
|
||||
{
|
||||
{
|
||||
quads[index].bl.colors = color4;
|
||||
quads[index].br.colors = color4;
|
||||
quads[index].tl.colors = color4;
|
||||
quads[index].tr.colors = color4;
|
||||
_textureAtlas->updateQuad(&quads[index], index);
|
||||
}
|
||||
}
|
||||
|
||||
bool Label::isCascadeColorEnabled() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void Label::setCascadeColorEnabled(bool cascadeColorEnabled)
|
||||
{
|
||||
_cascadeColorEnabled = cascadeColorEnabled;
|
||||
}
|
||||
}
|
||||
|
||||
std::string Label::getDescription() const
|
||||
|
@ -853,4 +742,4 @@ std::string Label::getDescription() const
|
|||
}
|
||||
|
||||
|
||||
NS_CC_END
|
||||
NS_CC_END
|
||||
|
|
|
@ -54,7 +54,7 @@ class FontAtlas;
|
|||
|
||||
|
||||
|
||||
class CC_DLL Label : public SpriteBatchNode, public LabelProtocol, public RGBAProtocol, public LabelTextFormatProtocol
|
||||
class CC_DLL Label : public SpriteBatchNode, public LabelProtocol, public LabelTextFormatProtocol
|
||||
{
|
||||
public:
|
||||
|
||||
|
@ -78,21 +78,9 @@ public:
|
|||
virtual float getScaleX() const;
|
||||
virtual float getScaleY() const;
|
||||
|
||||
// RGBAProtocol
|
||||
virtual bool isOpacityModifyRGB() const override;
|
||||
virtual void setOpacityModifyRGB(bool isOpacityModifyRGB) override;
|
||||
virtual void setOpacity(GLubyte opacity) override;
|
||||
virtual void updateDisplayedOpacity(GLubyte parentOpacity) override;
|
||||
virtual bool isCascadeOpacityEnabled() const override;
|
||||
virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled) override;
|
||||
virtual void setColor(const Color3B& color) override;
|
||||
virtual void updateDisplayedColor(const Color3B& parentColor) override;
|
||||
virtual bool isCascadeColorEnabled() const override;
|
||||
virtual void setCascadeColorEnabled(bool cascadeColorEnabled) override;
|
||||
virtual const Color3B& getColor(void) const override;
|
||||
virtual const Color3B& getDisplayedColor() const override;
|
||||
virtual unsigned char getOpacity() const override;
|
||||
virtual unsigned char getDisplayedOpacity() const override;
|
||||
|
||||
// CCLabelTextFormat protocol implementation
|
||||
virtual std::vector<LetterInfo> *getLettersInfo() override { return &_lettersInfo; };
|
||||
|
@ -155,9 +143,11 @@ private:
|
|||
bool setCurrentString(unsigned short *stringToSet);
|
||||
bool setOriginalString(unsigned short *stringToSet);
|
||||
void resetCurrentString();
|
||||
|
||||
Sprite * updateSpriteWithLetterDefinition(Sprite *spriteToUpdate, const FontLetterDefinition &theDefinition, Texture2D *theTexture);
|
||||
|
||||
|
||||
Sprite * updateSpriteWithLetterDefinition(Sprite *spriteToUpdate, const FontLetterDefinition &theDefinition, Texture2D *theTexture);
|
||||
|
||||
virtual void updateColor() override;
|
||||
|
||||
|
||||
//! used for optimization
|
||||
Sprite *_reusedLetter;
|
||||
|
@ -172,12 +162,6 @@ private:
|
|||
unsigned short int * _originalUTF16String;
|
||||
Size * _advances;
|
||||
FontAtlas * _fontAtlas;
|
||||
Color3B _displayedColor;
|
||||
Color3B _realColor;
|
||||
bool _cascadeColorEnabled;
|
||||
bool _cascadeOpacityEnabled;
|
||||
unsigned char _displayedOpacity;
|
||||
unsigned char _realOpacity;
|
||||
bool _isOpacityModifyRGB;
|
||||
|
||||
bool _useDistanceField;
|
||||
|
|
|
@ -532,12 +532,6 @@ LabelBMFont::LabelBMFont()
|
|||
, _lineBreakWithoutSpaces(false)
|
||||
, _imageOffset(Point::ZERO)
|
||||
, _reusedChar(nullptr)
|
||||
, _displayedOpacity(255)
|
||||
, _realOpacity(255)
|
||||
, _displayedColor(Color3B::WHITE)
|
||||
, _realColor(Color3B::WHITE)
|
||||
, _cascadeColorEnabled(true)
|
||||
, _cascadeOpacityEnabled(true)
|
||||
, _isOpacityModifyRGB(false)
|
||||
{
|
||||
|
||||
|
@ -767,67 +761,13 @@ void LabelBMFont::setCString(const char *label)
|
|||
setString(label);
|
||||
}
|
||||
|
||||
//LabelBMFont - RGBAProtocol protocol
|
||||
const Color3B& LabelBMFont::getColor() const
|
||||
{
|
||||
return _realColor;
|
||||
}
|
||||
|
||||
const Color3B& LabelBMFont::getDisplayedColor() const
|
||||
{
|
||||
return _displayedColor;
|
||||
}
|
||||
|
||||
void LabelBMFont::setColor(const Color3B& color)
|
||||
{
|
||||
_displayedColor = _realColor = color;
|
||||
|
||||
if( _cascadeColorEnabled ) {
|
||||
Color3B parentColor = Color3B::WHITE;
|
||||
RGBAProtocol* pParent = dynamic_cast<RGBAProtocol*>(_parent);
|
||||
if (pParent && pParent->isCascadeColorEnabled())
|
||||
{
|
||||
parentColor = pParent->getDisplayedColor();
|
||||
}
|
||||
this->updateDisplayedColor(parentColor);
|
||||
}
|
||||
}
|
||||
|
||||
GLubyte LabelBMFont::getOpacity(void) const
|
||||
{
|
||||
return _realOpacity;
|
||||
}
|
||||
|
||||
GLubyte LabelBMFont::getDisplayedOpacity(void) const
|
||||
{
|
||||
return _displayedOpacity;
|
||||
}
|
||||
|
||||
/** Override synthesized setOpacity to recurse items */
|
||||
void LabelBMFont::setOpacity(GLubyte opacity)
|
||||
{
|
||||
_displayedOpacity = _realOpacity = opacity;
|
||||
|
||||
if( _cascadeOpacityEnabled ) {
|
||||
GLubyte parentOpacity = 255;
|
||||
RGBAProtocol* pParent = dynamic_cast<RGBAProtocol*>(_parent);
|
||||
if (pParent && pParent->isCascadeOpacityEnabled())
|
||||
{
|
||||
parentOpacity = pParent->getDisplayedOpacity();
|
||||
}
|
||||
this->updateDisplayedOpacity(parentOpacity);
|
||||
}
|
||||
}
|
||||
|
||||
void LabelBMFont::setOpacityModifyRGB(bool var)
|
||||
{
|
||||
_isOpacityModifyRGB = var;
|
||||
for(const auto &child : _children) {
|
||||
RGBAProtocol *pRGBAProtocol = dynamic_cast<RGBAProtocol*>(child);
|
||||
if (pRGBAProtocol)
|
||||
{
|
||||
pRGBAProtocol->setOpacityModifyRGB(_isOpacityModifyRGB);
|
||||
}
|
||||
child->setOpacityModifyRGB(_isOpacityModifyRGB);
|
||||
}
|
||||
}
|
||||
bool LabelBMFont::isOpacityModifyRGB() const
|
||||
|
@ -835,48 +775,6 @@ bool LabelBMFont::isOpacityModifyRGB() const
|
|||
return _isOpacityModifyRGB;
|
||||
}
|
||||
|
||||
void LabelBMFont::updateDisplayedOpacity(GLubyte parentOpacity)
|
||||
{
|
||||
_displayedOpacity = _realOpacity * parentOpacity/255.0f;
|
||||
|
||||
for(const auto &child : _children) {
|
||||
Sprite *item = static_cast<Sprite*>( child );
|
||||
item->updateDisplayedOpacity(_displayedOpacity);
|
||||
}
|
||||
}
|
||||
|
||||
void LabelBMFont::updateDisplayedColor(const Color3B& parentColor)
|
||||
{
|
||||
_displayedColor.r = _realColor.r * parentColor.r/255.0f;
|
||||
_displayedColor.g = _realColor.g * parentColor.g/255.0f;
|
||||
_displayedColor.b = _realColor.b * parentColor.b/255.0f;
|
||||
|
||||
for(const auto &child : _children) {
|
||||
Sprite *item = static_cast<Sprite*>( child );
|
||||
item->updateDisplayedColor(_displayedColor);
|
||||
}
|
||||
}
|
||||
|
||||
bool LabelBMFont::isCascadeColorEnabled() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void LabelBMFont::setCascadeColorEnabled(bool cascadeColorEnabled)
|
||||
{
|
||||
_cascadeColorEnabled = cascadeColorEnabled;
|
||||
}
|
||||
|
||||
bool LabelBMFont::isCascadeOpacityEnabled() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void LabelBMFont::setCascadeOpacityEnabled(bool cascadeOpacityEnabled)
|
||||
{
|
||||
_cascadeOpacityEnabled = cascadeOpacityEnabled;
|
||||
}
|
||||
|
||||
// LabelBMFont - AnchorPoint
|
||||
void LabelBMFont::setAnchorPoint(const Point& point)
|
||||
{
|
||||
|
|
|
@ -190,7 +190,7 @@ http://www.angelcode.com/products/bmfont/ (Free, Windows only)
|
|||
@since v0.8
|
||||
*/
|
||||
|
||||
class CC_DLL LabelBMFont : public NewSpriteBatchNode, public LabelProtocol, public RGBAProtocol
|
||||
class CC_DLL LabelBMFont : public NewSpriteBatchNode, public LabelProtocol
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
@ -245,18 +245,6 @@ public:
|
|||
// RGBAProtocol
|
||||
virtual bool isOpacityModifyRGB() const;
|
||||
virtual void setOpacityModifyRGB(bool isOpacityModifyRGB);
|
||||
virtual GLubyte getOpacity() const;
|
||||
virtual GLubyte getDisplayedOpacity() const;
|
||||
virtual void setOpacity(GLubyte opacity);
|
||||
virtual void updateDisplayedOpacity(GLubyte parentOpacity);
|
||||
virtual bool isCascadeOpacityEnabled() const;
|
||||
virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled);
|
||||
virtual const Color3B& getColor(void) const;
|
||||
virtual const Color3B& getDisplayedColor() const;
|
||||
virtual void setColor(const Color3B& color);
|
||||
virtual void updateDisplayedColor(const Color3B& parentColor);
|
||||
virtual bool isCascadeColorEnabled() const;
|
||||
virtual void setCascadeColorEnabled(bool cascadeColorEnabled);
|
||||
|
||||
void setFntFile(const std::string& fntFile);
|
||||
const std::string& getFntFile() const;
|
||||
|
@ -298,13 +286,6 @@ protected:
|
|||
Sprite *_reusedChar;
|
||||
|
||||
// texture RGBA
|
||||
GLubyte _displayedOpacity;
|
||||
GLubyte _realOpacity;
|
||||
Color3B _displayedColor;
|
||||
Color3B _realColor;
|
||||
bool _cascadeColorEnabled;
|
||||
bool _cascadeOpacityEnabled;
|
||||
/** conforms to RGBAProtocol protocol */
|
||||
bool _isOpacityModifyRGB;
|
||||
|
||||
};
|
||||
|
|
|
@ -412,154 +412,17 @@ std::string Layer::getDescription() const
|
|||
return StringUtils::format("<Layer | Tag = %d>", _tag);
|
||||
}
|
||||
|
||||
__LayerRGBA::__LayerRGBA()
|
||||
{
|
||||
CCLOG("LayerRGBA deprecated.");
|
||||
}
|
||||
|
||||
|
||||
#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
|
||||
#pragma GCC diagnostic warning "-Wdeprecated-declarations"
|
||||
#elif _MSC_VER >= 1400 //vs 2005 or higher
|
||||
#pragma warning (pop)
|
||||
#endif
|
||||
// LayerRGBA
|
||||
LayerRGBA::LayerRGBA()
|
||||
: _displayedOpacity(255)
|
||||
, _realOpacity (255)
|
||||
, _displayedColor(Color3B::WHITE)
|
||||
, _realColor(Color3B::WHITE)
|
||||
, _cascadeOpacityEnabled(false)
|
||||
, _cascadeColorEnabled(false)
|
||||
{}
|
||||
|
||||
LayerRGBA::~LayerRGBA() {}
|
||||
|
||||
bool LayerRGBA::init()
|
||||
{
|
||||
if (Layer::init())
|
||||
{
|
||||
_displayedOpacity = _realOpacity = 255;
|
||||
_displayedColor = _realColor = Color3B::WHITE;
|
||||
setCascadeOpacityEnabled(false);
|
||||
setCascadeColorEnabled(false);
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
GLubyte LayerRGBA::getOpacity() const
|
||||
{
|
||||
return _realOpacity;
|
||||
}
|
||||
|
||||
GLubyte LayerRGBA::getDisplayedOpacity() const
|
||||
{
|
||||
return _displayedOpacity;
|
||||
}
|
||||
|
||||
/** Override synthesized setOpacity to recurse items */
|
||||
void LayerRGBA::setOpacity(GLubyte opacity)
|
||||
{
|
||||
_displayedOpacity = _realOpacity = opacity;
|
||||
|
||||
if( _cascadeOpacityEnabled )
|
||||
{
|
||||
GLubyte parentOpacity = 255;
|
||||
RGBAProtocol *parent = dynamic_cast<RGBAProtocol*>(_parent);
|
||||
if (parent && parent->isCascadeOpacityEnabled())
|
||||
{
|
||||
parentOpacity = parent->getDisplayedOpacity();
|
||||
}
|
||||
updateDisplayedOpacity(parentOpacity);
|
||||
}
|
||||
}
|
||||
|
||||
const Color3B& LayerRGBA::getColor() const
|
||||
{
|
||||
return _realColor;
|
||||
}
|
||||
|
||||
const Color3B& LayerRGBA::getDisplayedColor() const
|
||||
{
|
||||
return _displayedColor;
|
||||
}
|
||||
|
||||
void LayerRGBA::setColor(const Color3B& color)
|
||||
{
|
||||
_displayedColor = _realColor = color;
|
||||
|
||||
if (_cascadeColorEnabled)
|
||||
{
|
||||
Color3B parentColor = Color3B::WHITE;
|
||||
RGBAProtocol* parent = dynamic_cast<RGBAProtocol*>(_parent);
|
||||
if (parent && parent->isCascadeColorEnabled())
|
||||
{
|
||||
parentColor = parent->getDisplayedColor();
|
||||
}
|
||||
|
||||
updateDisplayedColor(parentColor);
|
||||
}
|
||||
}
|
||||
|
||||
void LayerRGBA::updateDisplayedOpacity(GLubyte parentOpacity)
|
||||
{
|
||||
_displayedOpacity = _realOpacity * parentOpacity/255.0;
|
||||
|
||||
if (_cascadeOpacityEnabled)
|
||||
{
|
||||
for(const auto &child : _children) {
|
||||
RGBAProtocol *item = dynamic_cast<RGBAProtocol*>(child);
|
||||
if (item)
|
||||
{
|
||||
item->updateDisplayedOpacity(_displayedOpacity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LayerRGBA::updateDisplayedColor(const Color3B& parentColor)
|
||||
{
|
||||
_displayedColor.r = _realColor.r * parentColor.r/255.0;
|
||||
_displayedColor.g = _realColor.g * parentColor.g/255.0;
|
||||
_displayedColor.b = _realColor.b * parentColor.b/255.0;
|
||||
|
||||
if (_cascadeColorEnabled)
|
||||
{
|
||||
for(const auto &child : _children) {
|
||||
RGBAProtocol *item = dynamic_cast<RGBAProtocol*>(child);
|
||||
if (item)
|
||||
{
|
||||
item->updateDisplayedColor(_displayedColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool LayerRGBA::isCascadeOpacityEnabled() const
|
||||
{
|
||||
return _cascadeOpacityEnabled;
|
||||
}
|
||||
|
||||
void LayerRGBA::setCascadeOpacityEnabled(bool cascadeOpacityEnabled)
|
||||
{
|
||||
_cascadeOpacityEnabled = cascadeOpacityEnabled;
|
||||
}
|
||||
|
||||
bool LayerRGBA::isCascadeColorEnabled() const
|
||||
{
|
||||
return _cascadeColorEnabled;
|
||||
}
|
||||
|
||||
void LayerRGBA::setCascadeColorEnabled(bool cascadeColorEnabled)
|
||||
{
|
||||
_cascadeColorEnabled = cascadeColorEnabled;
|
||||
}
|
||||
|
||||
std::string LayerRGBA::getDescription() const
|
||||
{
|
||||
return StringUtils::format("<LayerRGBA | Tag = %d>", _tag);
|
||||
}
|
||||
|
||||
/// LayerColor
|
||||
|
||||
LayerColor::LayerColor()
|
||||
|
@ -734,23 +597,10 @@ void LayerColor::onDraw()
|
|||
CC_INCREMENT_GL_DRAWS(1);
|
||||
}
|
||||
|
||||
void LayerColor::setColor(const Color3B &color)
|
||||
{
|
||||
LayerRGBA::setColor(color);
|
||||
updateColor();
|
||||
}
|
||||
|
||||
void LayerColor::setOpacity(GLubyte opacity)
|
||||
{
|
||||
LayerRGBA::setOpacity(opacity);
|
||||
updateColor();
|
||||
}
|
||||
|
||||
std::string LayerColor::getDescription() const
|
||||
{
|
||||
return StringUtils::format("<LayerColor | Tag = %d>", _tag);
|
||||
}
|
||||
|
||||
//
|
||||
// LayerGradient
|
||||
//
|
||||
|
|
|
@ -195,45 +195,38 @@ private:
|
|||
- RGB colors
|
||||
@since 2.1
|
||||
*/
|
||||
class CC_DLL LayerRGBA : public Layer, public RGBAProtocol
|
||||
class CC_DLL __LayerRGBA : public Layer, public __RGBAProtocol
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(LayerRGBA);
|
||||
|
||||
|
||||
CREATE_FUNC(__LayerRGBA);
|
||||
|
||||
|
||||
//
|
||||
// Overrides
|
||||
//
|
||||
virtual GLubyte getOpacity() const override;
|
||||
virtual GLubyte getDisplayedOpacity() const override;
|
||||
virtual void setOpacity(GLubyte opacity) override;
|
||||
virtual void updateDisplayedOpacity(GLubyte parentOpacity) override;
|
||||
virtual bool isCascadeOpacityEnabled() const override;
|
||||
virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled) override;
|
||||
|
||||
virtual const Color3B& getColor() const override;
|
||||
virtual const Color3B& getDisplayedColor() const override;
|
||||
virtual void setColor(const Color3B& color) override;
|
||||
virtual void updateDisplayedColor(const Color3B& parentColor) override;
|
||||
virtual bool isCascadeColorEnabled() const override;
|
||||
virtual void setCascadeColorEnabled(bool cascadeColorEnabled) override;
|
||||
virtual std::string getDescription() const override;
|
||||
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 void setOpacityModifyRGB(bool bValue) override {CC_UNUSED_PARAM(bValue);}
|
||||
virtual bool isOpacityModifyRGB() const override { return false; }
|
||||
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();
|
||||
virtual bool init();
|
||||
|
||||
GLubyte _displayedOpacity, _realOpacity;
|
||||
Color3B _displayedColor, _realColor;
|
||||
bool _cascadeOpacityEnabled, _cascadeColorEnabled;
|
||||
__LayerRGBA();
|
||||
virtual ~__LayerRGBA() {}
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(LayerRGBA);
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(__LayerRGBA);
|
||||
};
|
||||
|
||||
//
|
||||
|
@ -245,7 +238,7 @@ All features from Layer are valid, plus the following new features:
|
|||
- opacity
|
||||
- RGB colors
|
||||
*/
|
||||
class CC_DLL LayerColor : public LayerRGBA, public BlendProtocol
|
||||
class CC_DLL LayerColor : public Layer, public BlendProtocol
|
||||
#ifdef EMSCRIPTEN
|
||||
, public GLBufferedNode
|
||||
#endif // EMSCRIPTEN
|
||||
|
@ -272,9 +265,7 @@ public:
|
|||
//
|
||||
virtual void draw() override;
|
||||
virtual void onDraw();
|
||||
|
||||
virtual void setColor(const Color3B &color) override;
|
||||
virtual void setOpacity(GLubyte opacity) override;
|
||||
|
||||
virtual void setContentSize(const Size & var) override;
|
||||
/** BlendFunction. Conforms to BlendProtocol protocol */
|
||||
/**
|
||||
|
@ -300,7 +291,7 @@ protected:
|
|||
bool initWithColor(const Color4B& color, GLfloat width, GLfloat height);
|
||||
bool initWithColor(const Color4B& color);
|
||||
|
||||
virtual void updateColor();
|
||||
virtual void updateColor() override;
|
||||
|
||||
BlendFunc _blendFunc;
|
||||
Vertex2F _squareVertices[4];
|
||||
|
|
|
@ -48,7 +48,7 @@ NS_CC_BEGIN
|
|||
* - You can add MenuItem objects in runtime using addChild:
|
||||
* - But the only accepted children are MenuItem objects
|
||||
*/
|
||||
class CC_DLL Menu : public LayerRGBA
|
||||
class CC_DLL Menu : public Layer
|
||||
{
|
||||
public:
|
||||
enum class State
|
||||
|
|
|
@ -299,12 +299,12 @@ void MenuItemLabel::setEnabled(bool enabled)
|
|||
{
|
||||
if(enabled == false)
|
||||
{
|
||||
_colorBackup = dynamic_cast<RGBAProtocol*>(_label)->getColor();
|
||||
dynamic_cast<RGBAProtocol*>(_label)->setColor(_disabledColor);
|
||||
_colorBackup = _label->getColor();
|
||||
_label->setColor(_disabledColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
dynamic_cast<RGBAProtocol*>(_label)->setColor(_colorBackup);
|
||||
_label->setColor(_colorBackup);
|
||||
}
|
||||
}
|
||||
MenuItem::setEnabled(enabled);
|
||||
|
|
|
@ -56,7 +56,7 @@ class SpriteFrame;
|
|||
*
|
||||
* Subclass MenuItem (or any subclass) to create your custom MenuItem objects.
|
||||
*/
|
||||
class CC_DLL MenuItem : public NodeRGBA
|
||||
class CC_DLL MenuItem : public Node
|
||||
{
|
||||
public:
|
||||
/** Creates a MenuItem with no target/selector */
|
||||
|
|
|
@ -43,7 +43,7 @@ NS_CC_BEGIN
|
|||
/** MotionStreak.
|
||||
Creates a trailing path.
|
||||
*/
|
||||
class CC_DLL MotionStreak : public NodeRGBA, public TextureProtocol
|
||||
class CC_DLL MotionStreak : public Node, public TextureProtocol
|
||||
#ifdef EMSCRIPTEN
|
||||
, public GLBufferedNode
|
||||
#endif // EMSCRIPTEN
|
||||
|
|
|
@ -129,6 +129,12 @@ Node::Node(void)
|
|||
#ifdef CC_USE_PHYSICS
|
||||
, _physicsBody(nullptr)
|
||||
#endif
|
||||
, _displayedOpacity(255)
|
||||
, _realOpacity(255)
|
||||
, _displayedColor(Color3B::WHITE)
|
||||
, _realColor(Color3B::WHITE)
|
||||
, _cascadeColorEnabled(false)
|
||||
, _cascadeOpacityEnabled(false)
|
||||
{
|
||||
// set default scheduler and actionManager
|
||||
Director *director = Director::getInstance();
|
||||
|
@ -641,6 +647,16 @@ void Node::addChild(Node *child, int zOrder, int tag)
|
|||
child->onEnterTransitionDidFinish();
|
||||
}
|
||||
}
|
||||
|
||||
if (_cascadeColorEnabled)
|
||||
{
|
||||
updateCascadeColor();
|
||||
}
|
||||
|
||||
if (_cascadeOpacityEnabled)
|
||||
{
|
||||
updateCascadeOpacity();
|
||||
}
|
||||
}
|
||||
|
||||
void Node::addChild(Node *child, int zOrder)
|
||||
|
@ -1418,135 +1434,158 @@ PhysicsBody* Node::getPhysicsBody() const
|
|||
}
|
||||
#endif //CC_USE_PHYSICS
|
||||
|
||||
// NodeRGBA
|
||||
NodeRGBA::NodeRGBA()
|
||||
: _displayedOpacity(255)
|
||||
, _realOpacity(255)
|
||||
, _displayedColor(Color3B::WHITE)
|
||||
, _realColor(Color3B::WHITE)
|
||||
, _cascadeColorEnabled(false)
|
||||
, _cascadeOpacityEnabled(false)
|
||||
{}
|
||||
|
||||
NodeRGBA::~NodeRGBA() {}
|
||||
|
||||
bool NodeRGBA::init()
|
||||
{
|
||||
if (Node::init())
|
||||
{
|
||||
_displayedOpacity = _realOpacity = 255;
|
||||
_displayedColor = _realColor = Color3B::WHITE;
|
||||
_cascadeOpacityEnabled = _cascadeColorEnabled = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
GLubyte NodeRGBA::getOpacity(void) const
|
||||
GLubyte Node::getOpacity(void) const
|
||||
{
|
||||
return _realOpacity;
|
||||
}
|
||||
|
||||
GLubyte NodeRGBA::getDisplayedOpacity(void) const
|
||||
GLubyte Node::getDisplayedOpacity(void) const
|
||||
{
|
||||
return _displayedOpacity;
|
||||
}
|
||||
|
||||
void NodeRGBA::setOpacity(GLubyte opacity)
|
||||
void Node::setOpacity(GLubyte opacity)
|
||||
{
|
||||
_displayedOpacity = _realOpacity = opacity;
|
||||
|
||||
if (_cascadeOpacityEnabled)
|
||||
{
|
||||
GLubyte parentOpacity = 255;
|
||||
RGBAProtocol* pParent = dynamic_cast<RGBAProtocol*>(_parent);
|
||||
if (pParent && pParent->isCascadeOpacityEnabled())
|
||||
{
|
||||
parentOpacity = pParent->getDisplayedOpacity();
|
||||
}
|
||||
this->updateDisplayedOpacity(parentOpacity);
|
||||
}
|
||||
updateCascadeOpacity();
|
||||
}
|
||||
|
||||
void NodeRGBA::updateDisplayedOpacity(GLubyte parentOpacity)
|
||||
void Node::updateDisplayedOpacity(GLubyte parentOpacity)
|
||||
{
|
||||
_displayedOpacity = _realOpacity * parentOpacity/255.0;
|
||||
|
||||
updateColor();
|
||||
|
||||
if (_cascadeOpacityEnabled)
|
||||
{
|
||||
for(const auto &child : _children) {
|
||||
RGBAProtocol* item = dynamic_cast<RGBAProtocol*>(child);
|
||||
if (item)
|
||||
{
|
||||
item->updateDisplayedOpacity(_displayedOpacity);
|
||||
}
|
||||
for(auto child : _children){
|
||||
child->updateDisplayedOpacity(_displayedOpacity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool NodeRGBA::isCascadeOpacityEnabled(void) const
|
||||
bool Node::isCascadeOpacityEnabled(void) const
|
||||
{
|
||||
return _cascadeOpacityEnabled;
|
||||
}
|
||||
|
||||
void NodeRGBA::setCascadeOpacityEnabled(bool cascadeOpacityEnabled)
|
||||
void Node::setCascadeOpacityEnabled(bool cascadeOpacityEnabled)
|
||||
{
|
||||
if (_cascadeOpacityEnabled == cascadeOpacityEnabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_cascadeOpacityEnabled = cascadeOpacityEnabled;
|
||||
|
||||
if (cascadeOpacityEnabled)
|
||||
{
|
||||
updateCascadeOpacity();
|
||||
}
|
||||
else
|
||||
{
|
||||
disableCascadeOpacity();
|
||||
}
|
||||
}
|
||||
|
||||
const Color3B& NodeRGBA::getColor(void) const
|
||||
void Node::updateCascadeOpacity()
|
||||
{
|
||||
GLubyte parentOpacity = 255;
|
||||
|
||||
if (_parent != nullptr && _parent->isCascadeOpacityEnabled())
|
||||
{
|
||||
parentOpacity = _parent->getDisplayedOpacity();
|
||||
}
|
||||
|
||||
updateDisplayedOpacity(parentOpacity);
|
||||
}
|
||||
|
||||
void Node::disableCascadeOpacity()
|
||||
{
|
||||
_displayedOpacity = _realOpacity;
|
||||
|
||||
for(auto child : _children){
|
||||
child->updateDisplayedOpacity(255);
|
||||
}
|
||||
}
|
||||
|
||||
const Color3B& Node::getColor(void) const
|
||||
{
|
||||
return _realColor;
|
||||
}
|
||||
|
||||
const Color3B& NodeRGBA::getDisplayedColor() const
|
||||
const Color3B& Node::getDisplayedColor() const
|
||||
{
|
||||
return _displayedColor;
|
||||
}
|
||||
|
||||
void NodeRGBA::setColor(const Color3B& color)
|
||||
void Node::setColor(const Color3B& color)
|
||||
{
|
||||
_displayedColor = _realColor = color;
|
||||
|
||||
if (_cascadeColorEnabled)
|
||||
{
|
||||
Color3B parentColor = Color3B::WHITE;
|
||||
RGBAProtocol *parent = dynamic_cast<RGBAProtocol*>(_parent);
|
||||
if (parent && parent->isCascadeColorEnabled())
|
||||
{
|
||||
parentColor = parent->getDisplayedColor();
|
||||
}
|
||||
|
||||
updateDisplayedColor(parentColor);
|
||||
}
|
||||
updateCascadeColor();
|
||||
}
|
||||
|
||||
void NodeRGBA::updateDisplayedColor(const Color3B& parentColor)
|
||||
void Node::updateDisplayedColor(const Color3B& parentColor)
|
||||
{
|
||||
_displayedColor.r = _realColor.r * parentColor.r/255.0;
|
||||
_displayedColor.g = _realColor.g * parentColor.g/255.0;
|
||||
_displayedColor.b = _realColor.b * parentColor.b/255.0;
|
||||
updateColor();
|
||||
|
||||
if (_cascadeColorEnabled)
|
||||
{
|
||||
for(const auto &child : _children) {
|
||||
RGBAProtocol *item = dynamic_cast<RGBAProtocol*>(child);
|
||||
if (item)
|
||||
{
|
||||
item->updateDisplayedColor(_displayedColor);
|
||||
}
|
||||
for(const auto &child : _children){
|
||||
child->updateDisplayedColor(_displayedColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool NodeRGBA::isCascadeColorEnabled(void) const
|
||||
bool Node::isCascadeColorEnabled(void) const
|
||||
{
|
||||
return _cascadeColorEnabled;
|
||||
}
|
||||
|
||||
void NodeRGBA::setCascadeColorEnabled(bool cascadeColorEnabled)
|
||||
void Node::setCascadeColorEnabled(bool cascadeColorEnabled)
|
||||
{
|
||||
if (_cascadeColorEnabled == cascadeColorEnabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_cascadeColorEnabled = cascadeColorEnabled;
|
||||
|
||||
if (_cascadeColorEnabled)
|
||||
{
|
||||
updateCascadeColor();
|
||||
}
|
||||
else
|
||||
{
|
||||
disableCascadeColor();
|
||||
}
|
||||
}
|
||||
|
||||
void Node::updateCascadeColor()
|
||||
{
|
||||
Color3B parentColor = Color3B::WHITE;
|
||||
if (_parent && _parent->isCascadeColorEnabled())
|
||||
{
|
||||
parentColor = _parent->getDisplayedColor();
|
||||
}
|
||||
|
||||
updateDisplayedColor(parentColor);
|
||||
}
|
||||
|
||||
void Node::disableCascadeColor()
|
||||
{
|
||||
for(auto child : _children){
|
||||
child->updateDisplayedColor(Color3B::WHITE);
|
||||
}
|
||||
}
|
||||
|
||||
__NodeRGBA::__NodeRGBA()
|
||||
{
|
||||
CCLOG("NodeRGBA deprecated.");
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -48,7 +48,6 @@ class GridBase;
|
|||
class Point;
|
||||
class Touch;
|
||||
class Action;
|
||||
class RGBAProtocol;
|
||||
class LabelProtocol;
|
||||
class Scheduler;
|
||||
class ActionManager;
|
||||
|
@ -1394,6 +1393,24 @@ public:
|
|||
virtual bool updatePhysicsTransform();
|
||||
|
||||
#endif
|
||||
|
||||
// overrides
|
||||
virtual GLubyte getOpacity() const;
|
||||
virtual GLubyte getDisplayedOpacity() const;
|
||||
virtual void setOpacity(GLubyte opacity);
|
||||
virtual void updateDisplayedOpacity(GLubyte parentOpacity);
|
||||
virtual bool isCascadeOpacityEnabled() const;
|
||||
virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled);
|
||||
|
||||
virtual const Color3B& getColor(void) const;
|
||||
virtual const Color3B& getDisplayedColor() const;
|
||||
virtual void setColor(const Color3B& color);
|
||||
virtual void updateDisplayedColor(const Color3B& parentColor);
|
||||
virtual bool isCascadeColorEnabled() const;
|
||||
virtual void setCascadeColorEnabled(bool cascadeColorEnabled);
|
||||
|
||||
virtual void setOpacityModifyRGB(bool bValue) {CC_UNUSED_PARAM(bValue);}
|
||||
virtual bool isOpacityModifyRGB() const { return false; };
|
||||
|
||||
protected:
|
||||
// Nodes should be created using create();
|
||||
|
@ -1412,6 +1429,12 @@ protected:
|
|||
|
||||
/// Convert cocos2d coordinates to UI windows coordinate.
|
||||
Point convertToWindowSpace(const Point& nodePoint) const;
|
||||
|
||||
virtual void updateCascadeOpacity();
|
||||
virtual void disableCascadeOpacity();
|
||||
virtual void updateCascadeColor();
|
||||
virtual void disableCascadeColor();
|
||||
virtual void updateColor() {}
|
||||
|
||||
|
||||
float _rotationX; ///< rotation angle on x-axis
|
||||
|
@ -1484,6 +1507,14 @@ protected:
|
|||
#ifdef CC_USE_PHYSICS
|
||||
PhysicsBody* _physicsBody; ///< the physicsBody the node have
|
||||
#endif
|
||||
|
||||
// opacity controls
|
||||
GLubyte _displayedOpacity;
|
||||
GLubyte _realOpacity;
|
||||
Color3B _displayedColor;
|
||||
Color3B _realColor;
|
||||
bool _cascadeColorEnabled;
|
||||
bool _cascadeOpacityEnabled;
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(Node);
|
||||
|
@ -1492,49 +1523,41 @@ private:
|
|||
//#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 NodeRGBA : public Node, public RGBAProtocol
|
||||
class CC_DLL __NodeRGBA : public Node, public __RGBAProtocol
|
||||
{
|
||||
public:
|
||||
// overrides
|
||||
virtual GLubyte getOpacity() const override;
|
||||
virtual GLubyte getDisplayedOpacity() const override;
|
||||
virtual void setOpacity(GLubyte opacity) override;
|
||||
virtual void updateDisplayedOpacity(GLubyte parentOpacity) override;
|
||||
virtual bool isCascadeOpacityEnabled() const override;
|
||||
virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled) override;
|
||||
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;
|
||||
virtual const Color3B& getDisplayedColor() const override;
|
||||
virtual void setColor(const Color3B& color) override;
|
||||
virtual void updateDisplayedColor(const Color3B& parentColor) override;
|
||||
virtual bool isCascadeColorEnabled() const override;
|
||||
virtual void setCascadeColorEnabled(bool cascadeColorEnabled) override;
|
||||
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 {CC_UNUSED_PARAM(bValue);};
|
||||
virtual bool isOpacityModifyRGB() const override { return false; };
|
||||
virtual void setOpacityModifyRGB(bool bValue) override { return Node::setOpacityModifyRGB(bValue); }
|
||||
virtual bool isOpacityModifyRGB() const override { return Node::isOpacityModifyRGB(); }
|
||||
|
||||
protected:
|
||||
NodeRGBA();
|
||||
virtual ~NodeRGBA();
|
||||
virtual bool init();
|
||||
|
||||
GLubyte _displayedOpacity;
|
||||
GLubyte _realOpacity;
|
||||
Color3B _displayedColor;
|
||||
Color3B _realColor;
|
||||
bool _cascadeColorEnabled;
|
||||
bool _cascadeOpacityEnabled;
|
||||
__NodeRGBA();
|
||||
virtual ~__NodeRGBA() {}
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(NodeRGBA);
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(__NodeRGBA);
|
||||
};
|
||||
|
||||
// end of base_node group
|
||||
|
|
|
@ -43,7 +43,7 @@ struct _ccArray;
|
|||
The children will be moved faster / slower than the parent according the the parallax ratio.
|
||||
|
||||
*/
|
||||
class CC_DLL ParallaxNode : public Node
|
||||
class CC_DLL ParallaxNode : public Node
|
||||
{
|
||||
public:
|
||||
// Create a Parallax node
|
||||
|
|
|
@ -151,28 +151,6 @@ void ProgressTimer::setReverseProgress(bool reverse)
|
|||
}
|
||||
}
|
||||
|
||||
void ProgressTimer::setColor(const Color3B& color)
|
||||
{
|
||||
_sprite->setColor(color);
|
||||
updateColor();
|
||||
}
|
||||
|
||||
const Color3B& ProgressTimer::getColor() const
|
||||
{
|
||||
return _sprite->getColor();
|
||||
}
|
||||
|
||||
void ProgressTimer::setOpacity(GLubyte opacity)
|
||||
{
|
||||
_sprite->setOpacity(opacity);
|
||||
updateColor();
|
||||
}
|
||||
|
||||
GLubyte ProgressTimer::getOpacity() const
|
||||
{
|
||||
return _sprite->getOpacity();
|
||||
}
|
||||
|
||||
// Interval
|
||||
|
||||
///
|
||||
|
|
|
@ -43,7 +43,7 @@ NS_CC_BEGIN
|
|||
The progress can be Radial, Horizontal or vertical.
|
||||
@since v0.99.1
|
||||
*/
|
||||
class CC_DLL ProgressTimer : public NodeRGBA
|
||||
class CC_DLL ProgressTimer : public Node
|
||||
#ifdef EMSCRIPTEN
|
||||
, public GLBufferedNode
|
||||
#endif // EMSCRIPTEN
|
||||
|
@ -111,10 +111,6 @@ public:
|
|||
// Overrides
|
||||
virtual void draw(void) override;
|
||||
void setAnchorPoint(const Point& anchorPoint) override;
|
||||
virtual void setColor(const Color3B& color) override;
|
||||
virtual const Color3B& getColor() const override;
|
||||
virtual GLubyte getOpacity() const override;
|
||||
virtual void setOpacity(GLubyte opacity) override;
|
||||
|
||||
protected:
|
||||
/**
|
||||
|
@ -137,7 +133,7 @@ protected:
|
|||
void updateProgress(void);
|
||||
void updateBar(void);
|
||||
void updateRadial(void);
|
||||
void updateColor(void);
|
||||
virtual void updateColor(void) override;
|
||||
Point boundaryTexCoord(char index);
|
||||
|
||||
Type _type;
|
||||
|
|
|
@ -35,11 +35,11 @@ NS_CC_BEGIN
|
|||
/**
|
||||
* RGBA protocol that affects Node's color and opacity
|
||||
*/
|
||||
class CC_DLL RGBAProtocol
|
||||
class CC_DLL __RGBAProtocol
|
||||
{
|
||||
public:
|
||||
virtual ~RGBAProtocol() {}
|
||||
|
||||
virtual ~__RGBAProtocol() {}
|
||||
|
||||
/**
|
||||
* Changes the color with R,G,B bytes
|
||||
*
|
||||
|
@ -48,7 +48,7 @@ public:
|
|||
* @lua NA
|
||||
*/
|
||||
virtual void setColor(const Color3B& color) = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Returns color that is currently used.
|
||||
*
|
||||
|
@ -86,7 +86,7 @@ public:
|
|||
* @lua NA
|
||||
*/
|
||||
virtual GLubyte getOpacity() const = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Changes the opacity.
|
||||
*
|
||||
|
@ -95,11 +95,11 @@ public:
|
|||
* @lua NA
|
||||
*/
|
||||
virtual void setOpacity(GLubyte opacity) = 0;
|
||||
|
||||
|
||||
// optional
|
||||
|
||||
|
||||
/**
|
||||
* Changes the OpacityModifyRGB 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.
|
||||
*
|
||||
|
@ -109,9 +109,9 @@ public:
|
|||
* @lua NA
|
||||
*/
|
||||
virtual void setOpacityModifyRGB(bool value) = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Returns whether or not the opacity will be applied using glColor(R,G,B,opacity)
|
||||
* 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.
|
||||
|
@ -127,19 +127,19 @@ public:
|
|||
*/
|
||||
virtual bool isCascadeColorEnabled() const = 0;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void setCascadeColorEnabled(bool cascadeColorEnabled) = 0;
|
||||
|
||||
/**
|
||||
* recursive method that updates display color
|
||||
/**
|
||||
* 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
|
||||
|
|
|
@ -222,7 +222,7 @@ bool Sprite::initWithSpriteFrame(SpriteFrame *spriteFrame)
|
|||
// designated initializer
|
||||
bool Sprite::initWithTexture(Texture2D *texture, const Rect& rect, bool rotated)
|
||||
{
|
||||
if (NodeRGBA::init())
|
||||
if (Node::init())
|
||||
{
|
||||
_batchNode = nullptr;
|
||||
|
||||
|
@ -1075,20 +1075,6 @@ void Sprite::updateColor(void)
|
|||
// do nothing
|
||||
}
|
||||
|
||||
void Sprite::setOpacity(GLubyte opacity)
|
||||
{
|
||||
NodeRGBA::setOpacity(opacity);
|
||||
|
||||
updateColor();
|
||||
}
|
||||
|
||||
void Sprite::setColor(const Color3B& color3)
|
||||
{
|
||||
NodeRGBA::setColor(color3);
|
||||
|
||||
updateColor();
|
||||
}
|
||||
|
||||
void Sprite::setOpacityModifyRGB(bool modify)
|
||||
{
|
||||
if (_opacityModifyRGB != modify)
|
||||
|
@ -1103,20 +1089,6 @@ bool Sprite::isOpacityModifyRGB(void) const
|
|||
return _opacityModifyRGB;
|
||||
}
|
||||
|
||||
void Sprite::updateDisplayedColor(const Color3B& parentColor)
|
||||
{
|
||||
NodeRGBA::updateDisplayedColor(parentColor);
|
||||
|
||||
updateColor();
|
||||
}
|
||||
|
||||
void Sprite::updateDisplayedOpacity(GLubyte opacity)
|
||||
{
|
||||
NodeRGBA::updateDisplayedOpacity(opacity);
|
||||
|
||||
updateColor();
|
||||
}
|
||||
|
||||
// Frames
|
||||
|
||||
void Sprite::setSpriteFrame(const std::string &spriteFrameName)
|
||||
|
|
|
@ -78,7 +78,7 @@ struct transformValues_;
|
|||
*
|
||||
* The default anchorPoint in Sprite is (0.5, 0.5).
|
||||
*/
|
||||
class CC_DLL Sprite : public NodeRGBA, public TextureProtocol
|
||||
class CC_DLL Sprite : public Node, public TextureProtocol
|
||||
{
|
||||
public:
|
||||
|
||||
|
@ -426,16 +426,8 @@ public:
|
|||
virtual void setVisible(bool bVisible) override;
|
||||
virtual void updateQuadVertices();
|
||||
virtual void draw(void) override;
|
||||
/// @}
|
||||
|
||||
/// @{
|
||||
/// @name Functions inherited from NodeRGBA
|
||||
virtual void setColor(const Color3B& color3) override;
|
||||
virtual void updateDisplayedColor(const Color3B& parentColor) override;
|
||||
virtual void setOpacity(GLubyte opacity) override;
|
||||
virtual void setOpacityModifyRGB(bool modify) override;
|
||||
virtual bool isOpacityModifyRGB(void) const override;
|
||||
virtual void updateDisplayedOpacity(GLubyte parentOpacity) override;
|
||||
/// @}
|
||||
|
||||
protected:
|
||||
|
|
|
@ -497,7 +497,7 @@ void CCBAnimationManager::setAnimatedProperty(const std::string& propName, Node
|
|||
else if (propName == "opacity")
|
||||
{
|
||||
unsigned char opacity = value.asByte();
|
||||
(dynamic_cast<RGBAProtocol*>(pNode))->setOpacity(opacity);
|
||||
pNode->setOpacity(opacity);
|
||||
}
|
||||
else if (propName == "displayFrame")
|
||||
{
|
||||
|
@ -509,7 +509,7 @@ void CCBAnimationManager::setAnimatedProperty(const std::string& propName, Node
|
|||
unsigned char r = c["r"].asByte();
|
||||
unsigned char g = c["g"].asByte();
|
||||
unsigned char b = c["b"].asByte();
|
||||
(dynamic_cast<RGBAProtocol*>(pNode))->setColor(Color3B(r, g, b));
|
||||
pNode->setColor(Color3B(r, g, b));
|
||||
}
|
||||
else if (propName == "visible")
|
||||
{
|
||||
|
|
|
@ -67,7 +67,7 @@ CC_DEPRECATED_ATTRIBUTE typedef Armature CCArmature;
|
|||
CC_DEPRECATED_ATTRIBUTE typedef ArmatureDataManager CCArmatureDataManager;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef TweenType CCTweenType;
|
||||
|
||||
class Armature : public cocos2d::NodeRGBA, public cocos2d::BlendProtocol
|
||||
class Armature : public cocos2d::Node, public cocos2d::BlendProtocol
|
||||
{
|
||||
|
||||
public:
|
||||
|
|
|
@ -263,37 +263,22 @@ void CCBone::setBlendFunc(const BlendFunc& blendFunc)
|
|||
void Bone::updateDisplayedColor(const Color3B &parentColor)
|
||||
{
|
||||
_realColor = Color3B(255, 255, 255);
|
||||
NodeRGBA::updateDisplayedColor(parentColor);
|
||||
updateColor();
|
||||
Node::updateDisplayedColor(parentColor);
|
||||
}
|
||||
|
||||
void Bone::updateDisplayedOpacity(GLubyte parentOpacity)
|
||||
{
|
||||
_realOpacity = 255;
|
||||
NodeRGBA::updateDisplayedOpacity(parentOpacity);
|
||||
updateColor();
|
||||
}
|
||||
|
||||
void Bone::setColor(const Color3B& color)
|
||||
{
|
||||
NodeRGBA::setColor(color);
|
||||
updateColor();
|
||||
}
|
||||
|
||||
void Bone::setOpacity(GLubyte opacity)
|
||||
{
|
||||
NodeRGBA::setOpacity(opacity);
|
||||
updateColor();
|
||||
Node::updateDisplayedOpacity(parentOpacity);
|
||||
}
|
||||
|
||||
void Bone::updateColor()
|
||||
{
|
||||
Node *display = _displayManager->getDisplayRenderNode();
|
||||
RGBAProtocol *protocol = dynamic_cast<RGBAProtocol *>(display);
|
||||
if(protocol != nullptr)
|
||||
if(display != nullptr)
|
||||
{
|
||||
protocol->setColor(Color3B(_displayedColor.r * _tweenData->r / 255, _displayedColor.g * _tweenData->g / 255, _displayedColor.b * _tweenData->b / 255));
|
||||
protocol->setOpacity(_displayedOpacity * _tweenData->a / 255);
|
||||
display->setColor(Color3B(_displayedColor.r * _tweenData->r / 255, _displayedColor.g * _tweenData->g / 255, _displayedColor.b * _tweenData->b / 255));
|
||||
display->setOpacity(_displayedOpacity * _tweenData->a / 255);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace cocostudio {
|
|||
|
||||
class Armature;
|
||||
|
||||
class Bone : public cocos2d::NodeRGBA
|
||||
class Bone : public cocos2d::Node
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
@ -134,11 +134,8 @@ public:
|
|||
void updateDisplayedColor(const cocos2d::Color3B &parentColor) override;
|
||||
void updateDisplayedOpacity(GLubyte parentOpacity) override;
|
||||
|
||||
virtual void setColor(const cocos2d::Color3B& color) override;
|
||||
virtual void setOpacity(GLubyte opacity) override;
|
||||
|
||||
//! Update color to render display
|
||||
void updateColor();
|
||||
virtual void updateColor() override;
|
||||
|
||||
//! Update zorder
|
||||
void updateZOrder();
|
||||
|
|
|
@ -297,11 +297,8 @@ void DisplayManager::setCurrentDecorativeDisplay(DecorativeDisplay *decoDisplay)
|
|||
particle->resetSystem();
|
||||
}
|
||||
|
||||
if (RGBAProtocol *rgbaProtocaol = dynamic_cast<RGBAProtocol *>(_displayRenderNode))
|
||||
{
|
||||
rgbaProtocaol->setColor(_bone->getDisplayedColor());
|
||||
rgbaProtocaol->setOpacity(_bone->getDisplayedOpacity());
|
||||
}
|
||||
_displayRenderNode->setColor(_bone->getDisplayedColor());
|
||||
_displayRenderNode->setOpacity(_bone->getDisplayedOpacity());
|
||||
|
||||
_displayRenderNode->retain();
|
||||
_displayRenderNode->setVisible(_visible);
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace spine {
|
|||
/**
|
||||
Draws a skeleton.
|
||||
*/
|
||||
class CCSkeleton: public cocos2d::NodeRGBA, public cocos2d::BlendProtocol {
|
||||
class CCSkeleton: public cocos2d::Node, public cocos2d::BlendProtocol {
|
||||
public:
|
||||
static CCSkeleton* createWithData (SkeletonData* skeletonData, bool ownsSkeletonData = false);
|
||||
static CCSkeleton* createWithFile (const char* skeletonDataFile, Atlas* atlas, float scale = 1);
|
||||
|
|
|
@ -78,12 +78,8 @@ bool UILayout::init()
|
|||
initRenderer();
|
||||
_renderer->retain();
|
||||
_renderer->setZOrder(_widgetZOrder);
|
||||
cocos2d::RGBAProtocol* renderRGBA = dynamic_cast<cocos2d::RGBAProtocol*>(_renderer);
|
||||
if (renderRGBA)
|
||||
{
|
||||
renderRGBA->setCascadeColorEnabled(false);
|
||||
renderRGBA->setCascadeOpacityEnabled(false);
|
||||
}
|
||||
_renderer->setCascadeColorEnabled(false);
|
||||
_renderer->setCascadeOpacityEnabled(false);
|
||||
ignoreContentAdaptWithSize(false);
|
||||
setSize(cocos2d::Size::ZERO);
|
||||
setBright(true);
|
||||
|
@ -428,11 +424,7 @@ void UILayout::setColor(const cocos2d::Color3B &color)
|
|||
UIWidget::setColor(color);
|
||||
if (_backGroundImage)
|
||||
{
|
||||
cocos2d::RGBAProtocol* rgbap = dynamic_cast<cocos2d::RGBAProtocol*>(_backGroundImage);
|
||||
if (rgbap)
|
||||
{
|
||||
rgbap->setColor(color);
|
||||
}
|
||||
_backGroundImage->setColor(color);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -441,11 +433,7 @@ void UILayout::setOpacity(int opacity)
|
|||
UIWidget::setOpacity(opacity);
|
||||
if (_backGroundImage)
|
||||
{
|
||||
cocos2d::RGBAProtocol* rgbap = dynamic_cast<cocos2d::RGBAProtocol*>(_backGroundImage);
|
||||
if (rgbap)
|
||||
{
|
||||
rgbap->setOpacity(opacity);
|
||||
}
|
||||
_backGroundImage->setOpacity(opacity);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,8 +31,6 @@ namespace gui {
|
|||
|
||||
#define DYNAMIC_CAST_CCBLENDPROTOCOL dynamic_cast<cocos2d::BlendProtocol*>(_renderer)
|
||||
|
||||
#define DYNAMIC_CAST_CCRGBAPROTOCOL dynamic_cast<cocos2d::RGBAProtocol*>(_renderer)
|
||||
|
||||
#define DYNAMIC_CAST_CCNODERGBA dynamic_cast<GUIRenderer*>(_renderer)
|
||||
|
||||
UIWidget::UIWidget():
|
||||
|
@ -111,12 +109,8 @@ bool UIWidget::init()
|
|||
initRenderer();
|
||||
_renderer->retain();
|
||||
_renderer->setZOrder(_widgetZOrder);
|
||||
cocos2d::RGBAProtocol* renderRGBA = DYNAMIC_CAST_CCRGBAPROTOCOL;
|
||||
if (renderRGBA)
|
||||
{
|
||||
renderRGBA->setCascadeColorEnabled(true);
|
||||
renderRGBA->setCascadeOpacityEnabled(true);
|
||||
}
|
||||
_renderer->setCascadeColorEnabled(true);
|
||||
_renderer->setCascadeOpacityEnabled(true);
|
||||
setBright(true);
|
||||
ignoreContentAdaptWithSize(true);
|
||||
_scheduler = cocos2d::Director::getInstance()->getScheduler();
|
||||
|
@ -1050,78 +1044,42 @@ cocos2d::Action* UIWidget::getActionByTag(int tag)
|
|||
|
||||
void UIWidget::setColor(const cocos2d::Color3B &color)
|
||||
{
|
||||
cocos2d::RGBAProtocol* rgbap = DYNAMIC_CAST_CCRGBAPROTOCOL;
|
||||
if (rgbap)
|
||||
{
|
||||
rgbap->setColor(color);
|
||||
}
|
||||
_renderer->setColor(color);
|
||||
}
|
||||
|
||||
const cocos2d::Color3B& UIWidget::getColor()
|
||||
{
|
||||
cocos2d::RGBAProtocol* rgbap = DYNAMIC_CAST_CCRGBAPROTOCOL;
|
||||
if (rgbap)
|
||||
{
|
||||
return rgbap->getColor();
|
||||
}
|
||||
return cocos2d::Color3B::WHITE;
|
||||
return _renderer->getColor();
|
||||
}
|
||||
|
||||
void UIWidget::setOpacity(int opacity)
|
||||
{
|
||||
cocos2d::RGBAProtocol* rgbap = DYNAMIC_CAST_CCRGBAPROTOCOL;
|
||||
if (rgbap)
|
||||
{
|
||||
rgbap->setOpacity(opacity);
|
||||
}
|
||||
_renderer->setOpacity(opacity);
|
||||
}
|
||||
|
||||
int UIWidget::getOpacity()
|
||||
{
|
||||
cocos2d::RGBAProtocol* rgbap = DYNAMIC_CAST_CCRGBAPROTOCOL;
|
||||
if (rgbap)
|
||||
{
|
||||
return rgbap->getOpacity();
|
||||
}
|
||||
return 255;
|
||||
return _renderer->getOpacity();
|
||||
}
|
||||
|
||||
bool UIWidget::isCascadeOpacityEnabled()
|
||||
{
|
||||
cocos2d::RGBAProtocol* rgbap = DYNAMIC_CAST_CCRGBAPROTOCOL;
|
||||
if (rgbap)
|
||||
{
|
||||
return rgbap->isCascadeOpacityEnabled();
|
||||
}
|
||||
return false;
|
||||
return _renderer->isCascadeOpacityEnabled();
|
||||
}
|
||||
|
||||
void UIWidget::setCascadeOpacityEnabled(bool cascadeOpacityEnabled)
|
||||
{
|
||||
cocos2d::RGBAProtocol* rgbap = DYNAMIC_CAST_CCRGBAPROTOCOL;
|
||||
if (rgbap)
|
||||
{
|
||||
rgbap->setCascadeOpacityEnabled(cascadeOpacityEnabled);
|
||||
}
|
||||
_renderer->setCascadeOpacityEnabled(cascadeOpacityEnabled);
|
||||
}
|
||||
|
||||
bool UIWidget::isCascadeColorEnabled()
|
||||
{
|
||||
cocos2d::RGBAProtocol* rgbap = DYNAMIC_CAST_CCRGBAPROTOCOL;
|
||||
if (rgbap)
|
||||
{
|
||||
return rgbap->isCascadeColorEnabled();
|
||||
}
|
||||
return false;
|
||||
return _renderer->isCascadeColorEnabled();
|
||||
}
|
||||
|
||||
void UIWidget::setCascadeColorEnabled(bool cascadeColorEnabled)
|
||||
{
|
||||
cocos2d::RGBAProtocol* rgbap = DYNAMIC_CAST_CCRGBAPROTOCOL;
|
||||
if (rgbap)
|
||||
{
|
||||
rgbap->setCascadeColorEnabled(cascadeColorEnabled);
|
||||
}
|
||||
_renderer->setCascadeColorEnabled(cascadeColorEnabled);
|
||||
}
|
||||
|
||||
void UIWidget::setBlendFunc(cocos2d::BlendFunc blendFunc)
|
||||
|
@ -1309,7 +1267,7 @@ void GUIRenderer::visit()
|
|||
{
|
||||
return;
|
||||
}
|
||||
cocos2d::NodeRGBA::visit();
|
||||
cocos2d::Node::visit();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -994,7 +994,7 @@ protected:
|
|||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
class GUIRenderer : public cocos2d::NodeRGBA
|
||||
class GUIRenderer : public cocos2d::Node
|
||||
{
|
||||
public:
|
||||
GUIRenderer();
|
||||
|
|
|
@ -273,12 +273,20 @@ _G["CCFadeIn"] = DeprecatedClass.CCFadeIn()
|
|||
|
||||
--CCNodeRGBA class will be Deprecated,begin
|
||||
function DeprecatedClass.CCNodeRGBA()
|
||||
deprecatedTip("CCNodeRGBA","cc.NodeRGBA")
|
||||
return cc.NodeRGBA
|
||||
deprecatedTip("CCNodeRGBA","cc.Node")
|
||||
return cc.Node
|
||||
end
|
||||
_G["CCNodeRGBA"] = DeprecatedClass.CCNodeRGBA()
|
||||
--CCNodeRGBA class will be Deprecated,end
|
||||
|
||||
--NodeRGBA class will be Deprecated,begin
|
||||
function DeprecatedClass.NodeRGBA()
|
||||
deprecatedTip("cc.NodeRGBA","cc.Node")
|
||||
return cc.Node
|
||||
end
|
||||
_G["cc"]["NodeRGBA"] = DeprecatedClass.NodeRGBA()
|
||||
--NodeRGBA class will be Deprecated,end
|
||||
|
||||
--CCAnimationCache class will be Deprecated,begin
|
||||
function DeprecatedClass.CCAnimationCache()
|
||||
deprecatedTip("CCAnimationCache","cc.AnimationCache")
|
||||
|
@ -1305,12 +1313,20 @@ _G["CCCamera"] = DeprecatedClass.CCCamera()
|
|||
|
||||
--CCLayerRGBA class will be Deprecated,begin
|
||||
function DeprecatedClass.CCLayerRGBA()
|
||||
deprecatedTip("CCLayerRGBA","cc.LayerRGBA")
|
||||
return cc.LayerRGBA
|
||||
deprecatedTip("CCLayerRGBA","cc.Layer")
|
||||
return cc.Layer
|
||||
end
|
||||
_G["CCLayerRGBA"] = DeprecatedClass.CCLayerRGBA()
|
||||
--CCLayerRGBA class will be Deprecated,end
|
||||
|
||||
--LayerRGBA class will be Deprecated,begin
|
||||
function DeprecatedClass.LayerRGBA()
|
||||
deprecatedTip("cc.LayerRGBA","cc.Layer")
|
||||
return cc.Layer
|
||||
end
|
||||
_G["cc"]["LayerRGBA"] = DeprecatedClass.LayerRGBA()
|
||||
--LayerRGBA class will be Deprecated,end
|
||||
|
||||
--CCBezierTo class will be Deprecated,begin
|
||||
function DeprecatedClass.CCBezierTo()
|
||||
deprecatedTip("CCBezierTo","cc.BezierTo")
|
||||
|
|
|
@ -224,13 +224,9 @@ void Control::setOpacityModifyRGB(bool bOpacityModifyRGB)
|
|||
{
|
||||
_isOpacityModifyRGB=bOpacityModifyRGB;
|
||||
|
||||
std::for_each(_children.begin(), _children.end(), [&](Node* obj){
|
||||
RGBAProtocol* rgba = dynamic_cast<RGBAProtocol*>(obj);
|
||||
if (rgba)
|
||||
{
|
||||
rgba->setOpacityModifyRGB(bOpacityModifyRGB);
|
||||
}
|
||||
});
|
||||
for(auto child : _children){
|
||||
child->setOpacityModifyRGB(bOpacityModifyRGB);
|
||||
}
|
||||
}
|
||||
|
||||
bool Control::isOpacityModifyRGB() const
|
||||
|
|
|
@ -62,7 +62,7 @@ class Invocation;
|
|||
*
|
||||
* To use the Control you have to subclass it.
|
||||
*/
|
||||
class Control : public LayerRGBA
|
||||
class Control : public Layer
|
||||
{
|
||||
public:
|
||||
/** Kinds of possible events for the control objects. */
|
||||
|
|
|
@ -74,9 +74,8 @@ bool ControlButton::initWithLabelAndBackgroundSprite(Node* node, Scale9Sprite* b
|
|||
{
|
||||
CCASSERT(node != nullptr, "Label must not be nil.");
|
||||
LabelProtocol* label = dynamic_cast<LabelProtocol*>(node);
|
||||
RGBAProtocol* rgbaLabel = dynamic_cast<RGBAProtocol*>(node);
|
||||
CCASSERT(backgroundSprite != nullptr, "Background sprite must not be nil.");
|
||||
CCASSERT(label != nullptr || rgbaLabel!=nullptr || backgroundSprite != nullptr, "");
|
||||
CCASSERT(label != nullptr || backgroundSprite != nullptr, "");
|
||||
|
||||
_parentInited = true;
|
||||
|
||||
|
@ -105,7 +104,7 @@ bool ControlButton::initWithLabelAndBackgroundSprite(Node* node, Scale9Sprite* b
|
|||
// Initialize the dispatch table
|
||||
|
||||
setTitleForState(label->getString(), Control::State::NORMAL);
|
||||
setTitleColorForState(rgbaLabel->getColor(), Control::State::NORMAL);
|
||||
setTitleColorForState(node->getColor(), Control::State::NORMAL);
|
||||
setTitleLabelForState(node, Control::State::NORMAL);
|
||||
setBackgroundSpriteForState(backgroundSprite, Control::State::NORMAL);
|
||||
|
||||
|
@ -507,10 +506,9 @@ void ControlButton::needsLayout()
|
|||
label->setString(_currentTitle);
|
||||
}
|
||||
|
||||
RGBAProtocol* rgbaLabel = dynamic_cast<RGBAProtocol*>(_titleLabel);
|
||||
if (rgbaLabel)
|
||||
if (_titleLabel)
|
||||
{
|
||||
rgbaLabel->setColor(_currentTitleColor);
|
||||
_titleLabel->setColor(_currentTitleColor);
|
||||
}
|
||||
if (_titleLabel != nullptr)
|
||||
{
|
||||
|
|
|
@ -700,14 +700,9 @@ void Scale9Sprite::setOpacityModifyRGB(bool var)
|
|||
}
|
||||
_opacityModifyRGB = var;
|
||||
|
||||
auto& children = _scale9Image->getChildren();
|
||||
std::for_each(children.begin(), children.end(), [this](Node* child){
|
||||
RGBAProtocol* rgba = dynamic_cast<RGBAProtocol*>(child);
|
||||
if (rgba)
|
||||
{
|
||||
rgba->setOpacityModifyRGB(_opacityModifyRGB);
|
||||
}
|
||||
});
|
||||
for(auto child : _scale9Image->getChildren()){
|
||||
child->setOpacityModifyRGB(_opacityModifyRGB);
|
||||
}
|
||||
}
|
||||
|
||||
bool Scale9Sprite::isOpacityModifyRGB() const
|
||||
|
@ -788,21 +783,11 @@ void Scale9Sprite::setColor(const Color3B& color)
|
|||
return;
|
||||
}
|
||||
|
||||
NodeRGBA::setColor(color);
|
||||
Node::setColor(color);
|
||||
|
||||
auto& children = _scale9Image->getChildren();
|
||||
std::for_each(children.begin(), children.end(), [&color](Node* child){
|
||||
RGBAProtocol* rgba = dynamic_cast<RGBAProtocol*>(child);
|
||||
if (rgba)
|
||||
{
|
||||
rgba->setColor(color);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const Color3B& Scale9Sprite::getColor() const
|
||||
{
|
||||
return _realColor;
|
||||
for(auto child : _scale9Image->getChildren()){
|
||||
child->setColor(color);
|
||||
}
|
||||
}
|
||||
|
||||
void Scale9Sprite::setOpacity(GLubyte opacity)
|
||||
|
@ -811,21 +796,11 @@ void Scale9Sprite::setOpacity(GLubyte opacity)
|
|||
{
|
||||
return;
|
||||
}
|
||||
NodeRGBA::setOpacity(opacity);
|
||||
Node::setOpacity(opacity);
|
||||
|
||||
auto& children = _scale9Image->getChildren();
|
||||
std::for_each(children.begin(), children.end(), [&opacity](Node* child){
|
||||
RGBAProtocol* rgba = dynamic_cast<RGBAProtocol*>(child);
|
||||
if (rgba)
|
||||
{
|
||||
rgba->setOpacity(opacity);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
GLubyte Scale9Sprite::getOpacity() const
|
||||
{
|
||||
return _realOpacity;
|
||||
for(auto child : _scale9Image->getChildren()){
|
||||
child->setOpacity(opacity);
|
||||
}
|
||||
}
|
||||
|
||||
void Scale9Sprite::updateDisplayedColor(const cocos2d::Color3B &parentColor)
|
||||
|
@ -834,16 +809,11 @@ void Scale9Sprite::updateDisplayedColor(const cocos2d::Color3B &parentColor)
|
|||
{
|
||||
return;
|
||||
}
|
||||
NodeRGBA::updateDisplayedColor(parentColor);
|
||||
|
||||
auto& children = _scale9Image->getChildren();
|
||||
std::for_each(children.begin(), children.end(), [&parentColor](Node* child){
|
||||
RGBAProtocol* rgba = dynamic_cast<RGBAProtocol*>(child);
|
||||
if (rgba)
|
||||
{
|
||||
rgba->updateDisplayedColor(parentColor);
|
||||
}
|
||||
});
|
||||
Node::updateDisplayedColor(parentColor);
|
||||
|
||||
for(auto child : _scale9Image->getChildren()){
|
||||
child->updateDisplayedColor(parentColor);
|
||||
}
|
||||
}
|
||||
|
||||
void Scale9Sprite::updateDisplayedOpacity(GLubyte parentOpacity)
|
||||
|
@ -852,16 +822,11 @@ void Scale9Sprite::updateDisplayedOpacity(GLubyte parentOpacity)
|
|||
{
|
||||
return;
|
||||
}
|
||||
NodeRGBA::updateDisplayedOpacity(parentOpacity);
|
||||
Node::updateDisplayedOpacity(parentOpacity);
|
||||
|
||||
auto& children = _scale9Image->getChildren();
|
||||
std::for_each(children.begin(), children.end(), [&parentOpacity](Node* child){
|
||||
RGBAProtocol* rgba = dynamic_cast<RGBAProtocol*>(child);
|
||||
if (rgba)
|
||||
{
|
||||
rgba->updateDisplayedOpacity(parentOpacity);
|
||||
}
|
||||
});
|
||||
for(auto child : _scale9Image->getChildren()){
|
||||
child->updateDisplayedOpacity(parentOpacity);
|
||||
}
|
||||
}
|
||||
|
||||
NS_CC_EXT_END
|
||||
|
|
|
@ -50,7 +50,7 @@ NS_CC_EXT_BEGIN
|
|||
*
|
||||
* @see http://yannickloriot.com/library/ios/cccontrolextension/Classes/CCScale9Sprite.html
|
||||
*/
|
||||
class Scale9Sprite : public NodeRGBA
|
||||
class Scale9Sprite : public Node
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
@ -262,9 +262,7 @@ public:
|
|||
virtual void setOpacityModifyRGB(bool bValue) override;
|
||||
virtual bool isOpacityModifyRGB(void) const override;
|
||||
virtual void setOpacity(GLubyte opacity) override;
|
||||
virtual GLubyte getOpacity() const override;
|
||||
virtual void setColor(const Color3B& color) override;
|
||||
virtual const Color3B& getColor() const override;
|
||||
virtual void updateDisplayedOpacity(GLubyte parentOpacity) override;
|
||||
virtual void updateDisplayedColor(const Color3B& parentColor) override;
|
||||
|
||||
|
|
|
@ -644,7 +644,7 @@ void S9CascadeOpacityAndColor::onEnter()
|
|||
auto winSize = Director::getInstance()->getWinSize();
|
||||
float x = winSize.width / 2;
|
||||
float y = 0 + (winSize.height / 2);
|
||||
auto rgba = LayerRGBA::create();
|
||||
auto rgba = Layer::create();
|
||||
rgba->setCascadeColorEnabled(true);
|
||||
rgba->setCascadeOpacityEnabled(true);
|
||||
this->addChild(rgba);
|
||||
|
@ -672,7 +672,7 @@ void S9CascadeOpacityAndColor::onEnter()
|
|||
|
||||
std::string S9CascadeOpacityAndColor::title() const
|
||||
{
|
||||
return "Scale9Sprite and a LayerRGBA parent with setCascadeOpacityEnable(true) and setCascadeColorEnable(true)";
|
||||
return "Scale9Sprite and a Layer parent with setCascadeOpacityEnable(true) and setCascadeColorEnable(true)";
|
||||
}
|
||||
|
||||
std::string S9CascadeOpacityAndColor::subtitle() const
|
||||
|
|
|
@ -22,7 +22,9 @@ static std::function<Layer*()> createFunctions[] = {
|
|||
CL(LayerIgnoreAnchorPointPos),
|
||||
CL(LayerIgnoreAnchorPointRot),
|
||||
CL(LayerIgnoreAnchorPointScale),
|
||||
CL(LayerExtendedBlendOpacityTest)
|
||||
CL(LayerExtendedBlendOpacityTest),
|
||||
CL(LayerBug3162A),
|
||||
CL(LayerBug3162B),
|
||||
};
|
||||
|
||||
static int sceneIdx=-1;
|
||||
|
@ -112,12 +114,8 @@ void LayerTest::backCallback(Object* sender)
|
|||
|
||||
static void setEnableRecursiveCascading(Node* node, bool enable)
|
||||
{
|
||||
auto rgba = dynamic_cast<RGBAProtocol*>(node);
|
||||
if (rgba)
|
||||
{
|
||||
rgba->setCascadeColorEnabled(enable);
|
||||
rgba->setCascadeOpacityEnabled(enable);
|
||||
}
|
||||
node->setCascadeColorEnabled(enable);
|
||||
node->setCascadeOpacityEnabled(enable);
|
||||
|
||||
auto& children = node->getChildren();
|
||||
std::for_each(children.begin(), children.end(), [enable](Node* child){
|
||||
|
@ -131,7 +129,7 @@ void LayerTestCascadingOpacityA::onEnter()
|
|||
LayerTest::onEnter();
|
||||
|
||||
auto s = Director::getInstance()->getWinSize();
|
||||
auto layer1 = LayerRGBA::create();
|
||||
auto layer1 = Layer::create();
|
||||
|
||||
auto sister1 = Sprite::create("Images/grossinis_sister1.png");
|
||||
auto sister2 = Sprite::create("Images/grossinis_sister2.png");
|
||||
|
@ -170,7 +168,7 @@ void LayerTestCascadingOpacityA::onEnter()
|
|||
|
||||
std::string LayerTestCascadingOpacityA::title() const
|
||||
{
|
||||
return "LayerRGBA: cascading opacity";
|
||||
return "Layer: cascading opacity";
|
||||
}
|
||||
|
||||
|
||||
|
@ -284,7 +282,7 @@ void LayerTestCascadingColorA::onEnter()
|
|||
LayerTest::onEnter();
|
||||
|
||||
auto s = Director::getInstance()->getWinSize();
|
||||
auto layer1 = LayerRGBA::create();
|
||||
auto layer1 = Layer::create();
|
||||
|
||||
auto sister1 = Sprite::create("Images/grossinis_sister1.png");
|
||||
auto sister2 = Sprite::create("Images/grossinis_sister2.png");
|
||||
|
@ -326,7 +324,7 @@ void LayerTestCascadingColorA::onEnter()
|
|||
|
||||
std::string LayerTestCascadingColorA::title() const
|
||||
{
|
||||
return "LayerRGBA: cascading color";
|
||||
return "Layer: cascading color";
|
||||
}
|
||||
|
||||
|
||||
|
@ -868,3 +866,91 @@ std::string LayerExtendedBlendOpacityTest::subtitle() const
|
|||
return "You should see 3 layers";
|
||||
}
|
||||
|
||||
// LayerBug3162A
|
||||
void LayerBug3162A::onEnter()
|
||||
{
|
||||
LayerTest::onEnter();
|
||||
|
||||
Size size = VisibleRect::getVisibleRect().size;
|
||||
size.width = size.width / 2;
|
||||
size.height = size.height / 3;
|
||||
Color4B color[3] = {Color4B(255, 0, 0, 255), Color4B(0, 255, 0, 255), Color4B(0, 0, 255, 255)};
|
||||
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
_layer[i] = LayerColor::create(color[i]);
|
||||
_layer[i]->setContentSize(size);
|
||||
_layer[i]->setPosition(Point(size.width/2, size.height/2) - Point(20, 20));
|
||||
_layer[i]->setOpacity(150);
|
||||
_layer[i]->setCascadeOpacityEnabled(true);
|
||||
if (i > 0)
|
||||
{
|
||||
_layer[i-1]->addChild(_layer[i]);
|
||||
}
|
||||
}
|
||||
|
||||
this->addChild(_layer[0]);
|
||||
|
||||
schedule(schedule_selector(LayerBug3162A::step), 0.5, kRepeatForever, 0);
|
||||
}
|
||||
|
||||
void LayerBug3162A::step(float dt)
|
||||
{
|
||||
_layer[0]->setCascadeOpacityEnabled(!_layer[0]->isCascadeOpacityEnabled());
|
||||
}
|
||||
|
||||
std::string LayerBug3162A::title()
|
||||
{
|
||||
return "Bug 3162 red layer cascade opacity eable/disable";
|
||||
}
|
||||
|
||||
std::string LayerBug3162A::subtitle()
|
||||
{
|
||||
return "g and b layer opacity is effected/diseffected with r layer";
|
||||
}
|
||||
|
||||
// LayerBug3162B
|
||||
void LayerBug3162B::onEnter()
|
||||
{
|
||||
LayerTest::onEnter();
|
||||
|
||||
Size size = VisibleRect::getVisibleRect().size;
|
||||
size.width = size.width / 2;
|
||||
size.height = size.height / 3;
|
||||
Color4B color[3] = {Color4B(200, 0, 0, 255), Color4B(150, 0, 0, 255), Color4B(100, 0, 0, 255)};
|
||||
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
_layer[i] = LayerColor::create(color[i]);
|
||||
_layer[i]->setContentSize(size);
|
||||
_layer[i]->setPosition(Point(size.width/2, size.height/2) - Point(20, 20));
|
||||
//_layer[i]->setOpacity(150);
|
||||
if (i > 0)
|
||||
{
|
||||
_layer[i-1]->addChild(_layer[i]);
|
||||
}
|
||||
}
|
||||
|
||||
this->addChild(_layer[0]);
|
||||
|
||||
_layer[0]->setCascadeColorEnabled(true);
|
||||
_layer[1]->setCascadeColorEnabled(true);
|
||||
_layer[2]->setCascadeColorEnabled(true);
|
||||
|
||||
schedule(schedule_selector(LayerBug3162B::step), 0.5, kRepeatForever, 0);
|
||||
}
|
||||
|
||||
void LayerBug3162B::step(float dt)
|
||||
{
|
||||
_layer[0]->setCascadeColorEnabled(!_layer[0]->isCascadeColorEnabled());
|
||||
}
|
||||
|
||||
std::string LayerBug3162B::title()
|
||||
{
|
||||
return "Bug 3162 bottom layer cascade color eable/disable";
|
||||
}
|
||||
|
||||
std::string LayerBug3162B::subtitle()
|
||||
{
|
||||
return "u and m layer color is effected/diseffected with b layer";
|
||||
}
|
||||
|
|
|
@ -174,6 +174,34 @@ public:
|
|||
virtual std::string subtitle() const override;
|
||||
};
|
||||
|
||||
class LayerBug3162A : public LayerTest
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(LayerBug3162A);
|
||||
virtual void onEnter();
|
||||
virtual std::string title();
|
||||
virtual std::string subtitle();
|
||||
|
||||
void step(float dt);
|
||||
|
||||
private:
|
||||
LayerColor* _layer[3];
|
||||
};
|
||||
|
||||
class LayerBug3162B : public LayerTest
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(LayerBug3162B);
|
||||
virtual void onEnter();
|
||||
virtual std::string title();
|
||||
virtual std::string subtitle();
|
||||
|
||||
void step(float dt);
|
||||
|
||||
private:
|
||||
LayerColor* _layer[3];
|
||||
};
|
||||
|
||||
class LayerTestScene : public TestScene
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -62,9 +62,9 @@ end
|
|||
|
||||
-- LayerTestCascadingOpacityA
|
||||
local function LayerTestCascadingOpacityA()
|
||||
local ret = createLayerDemoLayer("LayerRGBA: cascading opacity")
|
||||
local ret = createLayerDemoLayer("Layer: cascading opacity")
|
||||
local s = cc.Director:getInstance():getWinSize()
|
||||
local layer1 = cc.LayerRGBA:create()
|
||||
local layer1 = cc.Layer:create()
|
||||
|
||||
local sister1 = cc.Sprite:create("Images/grossinis_sister1.png")
|
||||
local sister2 = cc.Sprite:create("Images/grossinis_sister2.png")
|
||||
|
@ -165,10 +165,10 @@ end
|
|||
|
||||
-- LayerTestCascadingColorA
|
||||
local function LayerTestCascadingColorA()
|
||||
local ret = createLayerDemoLayer("LayerRGBA: cascading color")
|
||||
local ret = createLayerDemoLayer("Layer: cascading color")
|
||||
|
||||
local s = cc.Director:getInstance():getWinSize()
|
||||
local layer1 = cc.LayerRGBA:create()
|
||||
local layer1 = cc.Layer:create()
|
||||
|
||||
local sister1 = cc.Sprite:create("Images/grossinis_sister1.png")
|
||||
local sister2 = cc.Sprite:create("Images/grossinis_sister2.png")
|
||||
|
|
|
@ -26,7 +26,7 @@ headers = %(cocosdir)s/cocos/2d/cocos2d.h %(cocosdir)s/cocos/audio/include/Simpl
|
|||
|
||||
# what classes to produce code for. You can use regular expressions here. When testing the regular
|
||||
# expression, it will be enclosed in "^$", like this: "^Menu*$".
|
||||
classes = New.* Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn Animat.* Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* TMX.* CallFunc RenderTexture GridAction Grid3DAction GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Speed ActionManager Set Data SimpleAudioEngine Scheduler Timer Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode .*3D$ Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram ShaderCache Application ClippingNode MotionStreak TextFieldTTF EGLViewProtocol EGLView Component
|
||||
classes = New.* Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn Animat.* Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* TMX.* CallFunc RenderTexture GridAction Grid3DAction GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Speed ActionManager Set Data SimpleAudioEngine Scheduler Timer Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode .*3D$ Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram ShaderCache Application ClippingNode MotionStreak TextFieldTTF EGLViewProtocol EGLView Component __NodeRGBA __LayerRGBA
|
||||
|
||||
classes_need_extend = Node Layer.* Sprite MenuItemFont Scene DrawNode
|
||||
|
||||
|
@ -126,7 +126,9 @@ rename_functions = SpriteFrameCache::[addSpriteFramesWithFile=addSpriteFrames ge
|
|||
FileUtils::[loadFilenameLookupDictionaryFromFile=loadFilenameLookup]
|
||||
|
||||
rename_classes = ParticleSystemQuad::ParticleSystem,
|
||||
SimpleAudioEngine::AudioEngine
|
||||
SimpleAudioEngine::AudioEngine,
|
||||
__NodeRGBA::NodeRGBA,
|
||||
__LayerRGBA::LayerRGBA
|
||||
|
||||
# for all class names, should we remove something when registering in the target VM?
|
||||
remove_prefix =
|
||||
|
|
Loading…
Reference in New Issue