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)
|
void FadeIn::update(float time)
|
||||||
{
|
{
|
||||||
RGBAProtocol *pRGBAProtocol = dynamic_cast<RGBAProtocol*>(_target);
|
if (_target)
|
||||||
if (pRGBAProtocol)
|
|
||||||
{
|
{
|
||||||
pRGBAProtocol->setOpacity((GLubyte)(255 * time));
|
_target->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)
|
void FadeOut::update(float time)
|
||||||
{
|
{
|
||||||
RGBAProtocol *pRGBAProtocol = dynamic_cast<RGBAProtocol*>(_target);
|
if (_target)
|
||||||
if (pRGBAProtocol)
|
|
||||||
{
|
{
|
||||||
pRGBAProtocol->setOpacity(GLubyte(255 * (1 - time)));
|
_target->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);
|
ActionInterval::startWithTarget(target);
|
||||||
|
|
||||||
RGBAProtocol *pRGBAProtocol = dynamic_cast<RGBAProtocol*>(target);
|
if (target)
|
||||||
if (pRGBAProtocol)
|
|
||||||
{
|
{
|
||||||
_fromOpacity = pRGBAProtocol->getOpacity();
|
_fromOpacity = target->getOpacity();
|
||||||
}
|
}
|
||||||
/*_fromOpacity = target->getOpacity();*/
|
/*_fromOpacity = target->getOpacity();*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void FadeTo::update(float time)
|
void FadeTo::update(float time)
|
||||||
{
|
{
|
||||||
RGBAProtocol *pRGBAProtocol = dynamic_cast<RGBAProtocol*>(_target);
|
if (_target)
|
||||||
if (pRGBAProtocol)
|
|
||||||
{
|
{
|
||||||
pRGBAProtocol->setOpacity((GLubyte)(_fromOpacity + (_toOpacity - _fromOpacity) * time));
|
_target->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)
|
void TintTo::startWithTarget(Node *target)
|
||||||
{
|
{
|
||||||
ActionInterval::startWithTarget(target);
|
ActionInterval::startWithTarget(target);
|
||||||
RGBAProtocol *pRGBAProtocol = dynamic_cast<RGBAProtocol*>(_target);
|
if (_target)
|
||||||
if (pRGBAProtocol)
|
|
||||||
{
|
{
|
||||||
_from = pRGBAProtocol->getColor();
|
_from = _target->getColor();
|
||||||
}
|
}
|
||||||
/*_from = target->getColor();*/
|
/*_from = target->getColor();*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void TintTo::update(float time)
|
void TintTo::update(float time)
|
||||||
{
|
{
|
||||||
RGBAProtocol *pRGBAProtocol = dynamic_cast<RGBAProtocol*>(_target);
|
if (_target)
|
||||||
if (pRGBAProtocol)
|
|
||||||
{
|
{
|
||||||
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.g + (_to.g - _from.g) * time),
|
||||||
(GLubyte)(_from.b + (_to.b - _from.b) * time)));
|
(GLubyte)(_from.b + (_to.b - _from.b) * time)));
|
||||||
}
|
}
|
||||||
|
@ -1836,10 +1830,9 @@ void TintBy::startWithTarget(Node *target)
|
||||||
{
|
{
|
||||||
ActionInterval::startWithTarget(target);
|
ActionInterval::startWithTarget(target);
|
||||||
|
|
||||||
RGBAProtocol *pRGBAProtocol = dynamic_cast<RGBAProtocol*>(target);
|
if (target)
|
||||||
if (pRGBAProtocol)
|
|
||||||
{
|
{
|
||||||
Color3B color = pRGBAProtocol->getColor();
|
Color3B color = target->getColor();
|
||||||
_fromR = color.r;
|
_fromR = color.r;
|
||||||
_fromG = color.g;
|
_fromG = color.g;
|
||||||
_fromB = color.b;
|
_fromB = color.b;
|
||||||
|
@ -1848,10 +1841,9 @@ void TintBy::startWithTarget(Node *target)
|
||||||
|
|
||||||
void TintBy::update(float time)
|
void TintBy::update(float time)
|
||||||
{
|
{
|
||||||
RGBAProtocol *pRGBAProtocol = dynamic_cast<RGBAProtocol*>(_target);
|
if (_target)
|
||||||
if (pRGBAProtocol)
|
|
||||||
{
|
{
|
||||||
pRGBAProtocol->setColor(Color3B((GLubyte)(_fromR + _deltaR * time),
|
_target->setColor(Color3B((GLubyte)(_fromR + _deltaR * time),
|
||||||
(GLubyte)(_fromG + _deltaG * time),
|
(GLubyte)(_fromG + _deltaG * time),
|
||||||
(GLubyte)(_fromB + _deltaB * time)));
|
(GLubyte)(_fromB + _deltaB * time)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,7 +173,7 @@ const Color3B& AtlasNode::getColor() const
|
||||||
{
|
{
|
||||||
return _colorUnmodified;
|
return _colorUnmodified;
|
||||||
}
|
}
|
||||||
return NodeRGBA::getColor();
|
return Node::getColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AtlasNode::setColor(const Color3B& color3)
|
void AtlasNode::setColor(const Color3B& color3)
|
||||||
|
@ -187,12 +187,12 @@ void AtlasNode::setColor(const Color3B& color3)
|
||||||
tmp.g = tmp.g * _displayedOpacity/255;
|
tmp.g = tmp.g * _displayedOpacity/255;
|
||||||
tmp.b = tmp.b * _displayedOpacity/255;
|
tmp.b = tmp.b * _displayedOpacity/255;
|
||||||
}
|
}
|
||||||
NodeRGBA::setColor(tmp);
|
Node::setColor(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AtlasNode::setOpacity(GLubyte opacity)
|
void AtlasNode::setOpacity(GLubyte opacity)
|
||||||
{
|
{
|
||||||
NodeRGBA::setOpacity(opacity);
|
Node::setOpacity(opacity);
|
||||||
|
|
||||||
// special opacity for premultiplied textures
|
// special opacity for premultiplied textures
|
||||||
if( _isOpacityModifyRGB )
|
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:
|
All features from Node are valid, plus the following features:
|
||||||
- opacity and RGB colors
|
- opacity and RGB colors
|
||||||
*/
|
*/
|
||||||
class CC_DLL AtlasNode : public NodeRGBA, public TextureProtocol
|
class CC_DLL AtlasNode : public Node, public TextureProtocol
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/** creates a AtlasNode with an Atlas file the width and height of each item and the quantity of items to render*/
|
/** 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 Touch CCTouch;
|
||||||
CC_DEPRECATED_ATTRIBUTE typedef Texture2D CCTexture2D;
|
CC_DEPRECATED_ATTRIBUTE typedef Texture2D CCTexture2D;
|
||||||
CC_DEPRECATED_ATTRIBUTE typedef Node CCNode;
|
CC_DEPRECATED_ATTRIBUTE typedef Node CCNode;
|
||||||
CC_DEPRECATED_ATTRIBUTE typedef NodeRGBA CCNodeRGBA;
|
CC_DEPRECATED_ATTRIBUTE typedef Node CCNodeRGBA;
|
||||||
CC_DEPRECATED_ATTRIBUTE typedef RGBAProtocol CCRGBAProtocol;
|
CC_DEPRECATED_ATTRIBUTE typedef Node CCRGBAProtocol;
|
||||||
CC_DEPRECATED_ATTRIBUTE typedef SpriteFrame CCSpriteFrame;
|
CC_DEPRECATED_ATTRIBUTE typedef SpriteFrame CCSpriteFrame;
|
||||||
CC_DEPRECATED_ATTRIBUTE typedef AnimationFrame CCAnimationFrame;
|
CC_DEPRECATED_ATTRIBUTE typedef AnimationFrame CCAnimationFrame;
|
||||||
CC_DEPRECATED_ATTRIBUTE typedef Animation CCAnimation;
|
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 LabelBMFont CCLabelBMFont;
|
||||||
CC_DEPRECATED_ATTRIBUTE typedef Layer CCLayer;
|
CC_DEPRECATED_ATTRIBUTE typedef Layer CCLayer;
|
||||||
//CC_DEPRECATED_ATTRIBUTE typedef KeypadDelegate CCKeypadDelegate;
|
//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 LayerColor CCLayerColor;
|
||||||
CC_DEPRECATED_ATTRIBUTE typedef LayerGradient CCLayerGradient;
|
CC_DEPRECATED_ATTRIBUTE typedef LayerGradient CCLayerGradient;
|
||||||
CC_DEPRECATED_ATTRIBUTE typedef LayerMultiplex CCLayerMultiplex;
|
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 CCString;
|
||||||
//CC_DEPRECATED_ATTRIBUTE typedef __String String;
|
//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
|
NS_CC_END
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -109,12 +109,6 @@ Label::Label(FontAtlas *atlas, TextHAlignment alignment, bool useDistanceField,b
|
||||||
, _originalUTF16String(0)
|
, _originalUTF16String(0)
|
||||||
, _advances(0)
|
, _advances(0)
|
||||||
, _fontAtlas(atlas)
|
, _fontAtlas(atlas)
|
||||||
, _displayedColor(Color3B::WHITE)
|
|
||||||
, _realColor(Color3B::WHITE)
|
|
||||||
, _cascadeColorEnabled(true)
|
|
||||||
, _cascadeOpacityEnabled(true)
|
|
||||||
, _displayedOpacity(255)
|
|
||||||
, _realOpacity(255)
|
|
||||||
, _isOpacityModifyRGB(true)
|
, _isOpacityModifyRGB(true)
|
||||||
,_useDistanceField(useDistanceField)
|
,_useDistanceField(useDistanceField)
|
||||||
,_useA8Shader(useA8Shader)
|
,_useA8Shader(useA8Shader)
|
||||||
|
@ -707,115 +701,20 @@ void Label::setOpacityModifyRGB(bool isOpacityModifyRGB)
|
||||||
_isOpacityModifyRGB = isOpacityModifyRGB;
|
_isOpacityModifyRGB = isOpacityModifyRGB;
|
||||||
|
|
||||||
for(const auto& child: _children) {
|
for(const auto& child: _children) {
|
||||||
RGBAProtocol *pRGBAProtocol = dynamic_cast<RGBAProtocol*>(child);
|
child->setOpacityModifyRGB(_isOpacityModifyRGB);
|
||||||
if (pRGBAProtocol)
|
|
||||||
{
|
|
||||||
pRGBAProtocol->setOpacityModifyRGB(_isOpacityModifyRGB);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_reusedLetter->setOpacityModifyRGB(true);
|
_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)
|
void Label::setColor(const Color3B& color)
|
||||||
{
|
{
|
||||||
_displayedColor = _realColor = color;
|
|
||||||
_reusedLetter->setColor(color);
|
_reusedLetter->setColor(color);
|
||||||
if( _cascadeColorEnabled )
|
SpriteBatchNode::setColor(color);
|
||||||
{
|
|
||||||
Color3B parentColor = Color3B::WHITE;
|
|
||||||
RGBAProtocol* pParent = dynamic_cast<RGBAProtocol*>(_parent);
|
|
||||||
|
|
||||||
if (pParent && pParent->isCascadeColorEnabled())
|
|
||||||
parentColor = pParent->getDisplayedColor();
|
|
||||||
|
|
||||||
updateDisplayedColor(parentColor);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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();
|
V3F_C4B_T2F_Quad *quads = _textureAtlas->getQuads();
|
||||||
auto count = _textureAtlas->getTotalQuads();
|
auto count = _textureAtlas->getTotalQuads();
|
||||||
Color4B color4( _displayedColor.r, _displayedColor.g, _displayedColor.b, _displayedOpacity );
|
Color4B color4( _displayedColor.r, _displayedColor.g, _displayedColor.b, _displayedOpacity );
|
||||||
|
@ -837,16 +736,6 @@ void Label::updateDisplayedColor(const Color3B& parentColor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Label::isCascadeColorEnabled() const
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Label::setCascadeColorEnabled(bool cascadeColorEnabled)
|
|
||||||
{
|
|
||||||
_cascadeColorEnabled = cascadeColorEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string Label::getDescription() const
|
std::string Label::getDescription() const
|
||||||
{
|
{
|
||||||
return StringUtils::format("<Label | Tag = %d, Label = '%s'>", _tag, cc_utf16_to_utf8(_currentUTF16String,-1,nullptr,nullptr));
|
return StringUtils::format("<Label | Tag = %d, Label = '%s'>", _tag, cc_utf16_to_utf8(_currentUTF16String,-1,nullptr,nullptr));
|
||||||
|
|
|
@ -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:
|
public:
|
||||||
|
|
||||||
|
@ -78,21 +78,9 @@ public:
|
||||||
virtual float getScaleX() const;
|
virtual float getScaleX() const;
|
||||||
virtual float getScaleY() const;
|
virtual float getScaleY() const;
|
||||||
|
|
||||||
// RGBAProtocol
|
|
||||||
virtual bool isOpacityModifyRGB() const override;
|
virtual bool isOpacityModifyRGB() const override;
|
||||||
virtual void setOpacityModifyRGB(bool isOpacityModifyRGB) 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 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
|
// CCLabelTextFormat protocol implementation
|
||||||
virtual std::vector<LetterInfo> *getLettersInfo() override { return &_lettersInfo; };
|
virtual std::vector<LetterInfo> *getLettersInfo() override { return &_lettersInfo; };
|
||||||
|
@ -158,6 +146,8 @@ private:
|
||||||
|
|
||||||
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
|
//! used for optimization
|
||||||
Sprite *_reusedLetter;
|
Sprite *_reusedLetter;
|
||||||
|
@ -172,12 +162,6 @@ private:
|
||||||
unsigned short int * _originalUTF16String;
|
unsigned short int * _originalUTF16String;
|
||||||
Size * _advances;
|
Size * _advances;
|
||||||
FontAtlas * _fontAtlas;
|
FontAtlas * _fontAtlas;
|
||||||
Color3B _displayedColor;
|
|
||||||
Color3B _realColor;
|
|
||||||
bool _cascadeColorEnabled;
|
|
||||||
bool _cascadeOpacityEnabled;
|
|
||||||
unsigned char _displayedOpacity;
|
|
||||||
unsigned char _realOpacity;
|
|
||||||
bool _isOpacityModifyRGB;
|
bool _isOpacityModifyRGB;
|
||||||
|
|
||||||
bool _useDistanceField;
|
bool _useDistanceField;
|
||||||
|
|
|
@ -532,12 +532,6 @@ LabelBMFont::LabelBMFont()
|
||||||
, _lineBreakWithoutSpaces(false)
|
, _lineBreakWithoutSpaces(false)
|
||||||
, _imageOffset(Point::ZERO)
|
, _imageOffset(Point::ZERO)
|
||||||
, _reusedChar(nullptr)
|
, _reusedChar(nullptr)
|
||||||
, _displayedOpacity(255)
|
|
||||||
, _realOpacity(255)
|
|
||||||
, _displayedColor(Color3B::WHITE)
|
|
||||||
, _realColor(Color3B::WHITE)
|
|
||||||
, _cascadeColorEnabled(true)
|
|
||||||
, _cascadeOpacityEnabled(true)
|
|
||||||
, _isOpacityModifyRGB(false)
|
, _isOpacityModifyRGB(false)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -767,67 +761,13 @@ void LabelBMFont::setCString(const char *label)
|
||||||
setString(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 */
|
/** 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)
|
void LabelBMFont::setOpacityModifyRGB(bool var)
|
||||||
{
|
{
|
||||||
_isOpacityModifyRGB = var;
|
_isOpacityModifyRGB = var;
|
||||||
for(const auto &child : _children) {
|
for(const auto &child : _children) {
|
||||||
RGBAProtocol *pRGBAProtocol = dynamic_cast<RGBAProtocol*>(child);
|
child->setOpacityModifyRGB(_isOpacityModifyRGB);
|
||||||
if (pRGBAProtocol)
|
|
||||||
{
|
|
||||||
pRGBAProtocol->setOpacityModifyRGB(_isOpacityModifyRGB);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool LabelBMFont::isOpacityModifyRGB() const
|
bool LabelBMFont::isOpacityModifyRGB() const
|
||||||
|
@ -835,48 +775,6 @@ bool LabelBMFont::isOpacityModifyRGB() const
|
||||||
return _isOpacityModifyRGB;
|
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
|
// LabelBMFont - AnchorPoint
|
||||||
void LabelBMFont::setAnchorPoint(const Point& point)
|
void LabelBMFont::setAnchorPoint(const Point& point)
|
||||||
{
|
{
|
||||||
|
|
|
@ -190,7 +190,7 @@ http://www.angelcode.com/products/bmfont/ (Free, Windows only)
|
||||||
@since v0.8
|
@since v0.8
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class CC_DLL LabelBMFont : public NewSpriteBatchNode, public LabelProtocol, public RGBAProtocol
|
class CC_DLL LabelBMFont : public NewSpriteBatchNode, public LabelProtocol
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
|
@ -245,18 +245,6 @@ public:
|
||||||
// RGBAProtocol
|
// RGBAProtocol
|
||||||
virtual bool isOpacityModifyRGB() const;
|
virtual bool isOpacityModifyRGB() const;
|
||||||
virtual void setOpacityModifyRGB(bool isOpacityModifyRGB);
|
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);
|
void setFntFile(const std::string& fntFile);
|
||||||
const std::string& getFntFile() const;
|
const std::string& getFntFile() const;
|
||||||
|
@ -298,13 +286,6 @@ protected:
|
||||||
Sprite *_reusedChar;
|
Sprite *_reusedChar;
|
||||||
|
|
||||||
// texture RGBA
|
// texture RGBA
|
||||||
GLubyte _displayedOpacity;
|
|
||||||
GLubyte _realOpacity;
|
|
||||||
Color3B _displayedColor;
|
|
||||||
Color3B _realColor;
|
|
||||||
bool _cascadeColorEnabled;
|
|
||||||
bool _cascadeOpacityEnabled;
|
|
||||||
/** conforms to RGBAProtocol protocol */
|
|
||||||
bool _isOpacityModifyRGB;
|
bool _isOpacityModifyRGB;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -412,154 +412,17 @@ std::string Layer::getDescription() const
|
||||||
return StringUtils::format("<Layer | Tag = %d>", _tag);
|
return StringUtils::format("<Layer | Tag = %d>", _tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__LayerRGBA::__LayerRGBA()
|
||||||
|
{
|
||||||
|
CCLOG("LayerRGBA deprecated.");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
|
#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
|
||||||
#pragma GCC diagnostic warning "-Wdeprecated-declarations"
|
#pragma GCC diagnostic warning "-Wdeprecated-declarations"
|
||||||
#elif _MSC_VER >= 1400 //vs 2005 or higher
|
#elif _MSC_VER >= 1400 //vs 2005 or higher
|
||||||
#pragma warning (pop)
|
#pragma warning (pop)
|
||||||
#endif
|
#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::LayerColor()
|
LayerColor::LayerColor()
|
||||||
|
@ -734,23 +597,10 @@ void LayerColor::onDraw()
|
||||||
CC_INCREMENT_GL_DRAWS(1);
|
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
|
std::string LayerColor::getDescription() const
|
||||||
{
|
{
|
||||||
return StringUtils::format("<LayerColor | Tag = %d>", _tag);
|
return StringUtils::format("<LayerColor | Tag = %d>", _tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// LayerGradient
|
// LayerGradient
|
||||||
//
|
//
|
||||||
|
|
|
@ -195,45 +195,38 @@ private:
|
||||||
- RGB colors
|
- RGB colors
|
||||||
@since 2.1
|
@since 2.1
|
||||||
*/
|
*/
|
||||||
class CC_DLL LayerRGBA : public Layer, public RGBAProtocol
|
class CC_DLL __LayerRGBA : public Layer, public __RGBAProtocol
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CREATE_FUNC(LayerRGBA);
|
CREATE_FUNC(__LayerRGBA);
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Overrides
|
// Overrides
|
||||||
//
|
//
|
||||||
virtual GLubyte getOpacity() const override;
|
virtual GLubyte getOpacity() const override { return Layer::getOpacity(); }
|
||||||
virtual GLubyte getDisplayedOpacity() const override;
|
virtual GLubyte getDisplayedOpacity() const override { return Layer::getDisplayedOpacity(); }
|
||||||
virtual void setOpacity(GLubyte opacity) override;
|
virtual void setOpacity(GLubyte opacity) override { return Layer::setOpacity(opacity); }
|
||||||
virtual void updateDisplayedOpacity(GLubyte parentOpacity) override;
|
virtual void updateDisplayedOpacity(GLubyte parentOpacity) override { return Layer::updateDisplayedOpacity(parentOpacity); }
|
||||||
virtual bool isCascadeOpacityEnabled() const override;
|
virtual bool isCascadeOpacityEnabled() const override { return Layer::isCascadeOpacityEnabled(); }
|
||||||
virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled) override;
|
virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled) override { return Layer::setCascadeOpacityEnabled(cascadeOpacityEnabled); }
|
||||||
|
|
||||||
virtual const Color3B& getColor() const override;
|
virtual const Color3B& getColor() const override { return Layer::getColor(); }
|
||||||
virtual const Color3B& getDisplayedColor() const override;
|
virtual const Color3B& getDisplayedColor() const override { return Layer::getDisplayedColor(); }
|
||||||
virtual void setColor(const Color3B& color) override;
|
virtual void setColor(const Color3B& color) override { return Layer::setColor(color); }
|
||||||
virtual void updateDisplayedColor(const Color3B& parentColor) override;
|
virtual void updateDisplayedColor(const Color3B& parentColor) override { return Layer::updateDisplayedColor(parentColor); }
|
||||||
virtual bool isCascadeColorEnabled() const override;
|
virtual bool isCascadeColorEnabled() const override { return Layer::isCascadeOpacityEnabled(); }
|
||||||
virtual void setCascadeColorEnabled(bool cascadeColorEnabled) override;
|
virtual void setCascadeColorEnabled(bool cascadeColorEnabled) override { return Layer::setCascadeColorEnabled(cascadeColorEnabled); }
|
||||||
virtual std::string getDescription() const override;
|
|
||||||
|
|
||||||
virtual void setOpacityModifyRGB(bool bValue) override {CC_UNUSED_PARAM(bValue);}
|
|
||||||
virtual bool isOpacityModifyRGB() const override { return false; }
|
|
||||||
|
|
||||||
|
virtual void setOpacityModifyRGB(bool bValue) override { return Layer::setOpacityModifyRGB(bValue); }
|
||||||
|
virtual bool isOpacityModifyRGB() const override { return Layer::isOpacityModifyRGB(); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
LayerRGBA();
|
__LayerRGBA();
|
||||||
virtual ~LayerRGBA();
|
virtual ~__LayerRGBA() {}
|
||||||
virtual bool init();
|
|
||||||
|
|
||||||
GLubyte _displayedOpacity, _realOpacity;
|
|
||||||
Color3B _displayedColor, _realColor;
|
|
||||||
bool _cascadeOpacityEnabled, _cascadeColorEnabled;
|
|
||||||
|
|
||||||
private:
|
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
|
- opacity
|
||||||
- RGB colors
|
- RGB colors
|
||||||
*/
|
*/
|
||||||
class CC_DLL LayerColor : public LayerRGBA, public BlendProtocol
|
class CC_DLL LayerColor : public Layer, public BlendProtocol
|
||||||
#ifdef EMSCRIPTEN
|
#ifdef EMSCRIPTEN
|
||||||
, public GLBufferedNode
|
, public GLBufferedNode
|
||||||
#endif // EMSCRIPTEN
|
#endif // EMSCRIPTEN
|
||||||
|
@ -273,8 +266,6 @@ public:
|
||||||
virtual void draw() override;
|
virtual void draw() override;
|
||||||
virtual void onDraw();
|
virtual void onDraw();
|
||||||
|
|
||||||
virtual void setColor(const Color3B &color) override;
|
|
||||||
virtual void setOpacity(GLubyte opacity) override;
|
|
||||||
virtual void setContentSize(const Size & var) override;
|
virtual void setContentSize(const Size & var) override;
|
||||||
/** BlendFunction. Conforms to BlendProtocol protocol */
|
/** BlendFunction. Conforms to BlendProtocol protocol */
|
||||||
/**
|
/**
|
||||||
|
@ -300,7 +291,7 @@ protected:
|
||||||
bool initWithColor(const Color4B& color, GLfloat width, GLfloat height);
|
bool initWithColor(const Color4B& color, GLfloat width, GLfloat height);
|
||||||
bool initWithColor(const Color4B& color);
|
bool initWithColor(const Color4B& color);
|
||||||
|
|
||||||
virtual void updateColor();
|
virtual void updateColor() override;
|
||||||
|
|
||||||
BlendFunc _blendFunc;
|
BlendFunc _blendFunc;
|
||||||
Vertex2F _squareVertices[4];
|
Vertex2F _squareVertices[4];
|
||||||
|
|
|
@ -48,7 +48,7 @@ NS_CC_BEGIN
|
||||||
* - You can add MenuItem objects in runtime using addChild:
|
* - You can add MenuItem objects in runtime using addChild:
|
||||||
* - But the only accepted children are MenuItem objects
|
* - But the only accepted children are MenuItem objects
|
||||||
*/
|
*/
|
||||||
class CC_DLL Menu : public LayerRGBA
|
class CC_DLL Menu : public Layer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum class State
|
enum class State
|
||||||
|
|
|
@ -299,12 +299,12 @@ void MenuItemLabel::setEnabled(bool enabled)
|
||||||
{
|
{
|
||||||
if(enabled == false)
|
if(enabled == false)
|
||||||
{
|
{
|
||||||
_colorBackup = dynamic_cast<RGBAProtocol*>(_label)->getColor();
|
_colorBackup = _label->getColor();
|
||||||
dynamic_cast<RGBAProtocol*>(_label)->setColor(_disabledColor);
|
_label->setColor(_disabledColor);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dynamic_cast<RGBAProtocol*>(_label)->setColor(_colorBackup);
|
_label->setColor(_colorBackup);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MenuItem::setEnabled(enabled);
|
MenuItem::setEnabled(enabled);
|
||||||
|
|
|
@ -56,7 +56,7 @@ class SpriteFrame;
|
||||||
*
|
*
|
||||||
* Subclass MenuItem (or any subclass) to create your custom MenuItem objects.
|
* Subclass MenuItem (or any subclass) to create your custom MenuItem objects.
|
||||||
*/
|
*/
|
||||||
class CC_DLL MenuItem : public NodeRGBA
|
class CC_DLL MenuItem : public Node
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/** Creates a MenuItem with no target/selector */
|
/** Creates a MenuItem with no target/selector */
|
||||||
|
|
|
@ -43,7 +43,7 @@ NS_CC_BEGIN
|
||||||
/** MotionStreak.
|
/** MotionStreak.
|
||||||
Creates a trailing path.
|
Creates a trailing path.
|
||||||
*/
|
*/
|
||||||
class CC_DLL MotionStreak : public NodeRGBA, public TextureProtocol
|
class CC_DLL MotionStreak : public Node, public TextureProtocol
|
||||||
#ifdef EMSCRIPTEN
|
#ifdef EMSCRIPTEN
|
||||||
, public GLBufferedNode
|
, public GLBufferedNode
|
||||||
#endif // EMSCRIPTEN
|
#endif // EMSCRIPTEN
|
||||||
|
|
|
@ -129,6 +129,12 @@ Node::Node(void)
|
||||||
#ifdef CC_USE_PHYSICS
|
#ifdef CC_USE_PHYSICS
|
||||||
, _physicsBody(nullptr)
|
, _physicsBody(nullptr)
|
||||||
#endif
|
#endif
|
||||||
|
, _displayedOpacity(255)
|
||||||
|
, _realOpacity(255)
|
||||||
|
, _displayedColor(Color3B::WHITE)
|
||||||
|
, _realColor(Color3B::WHITE)
|
||||||
|
, _cascadeColorEnabled(false)
|
||||||
|
, _cascadeOpacityEnabled(false)
|
||||||
{
|
{
|
||||||
// set default scheduler and actionManager
|
// set default scheduler and actionManager
|
||||||
Director *director = Director::getInstance();
|
Director *director = Director::getInstance();
|
||||||
|
@ -641,6 +647,16 @@ void Node::addChild(Node *child, int zOrder, int tag)
|
||||||
child->onEnterTransitionDidFinish();
|
child->onEnterTransitionDidFinish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_cascadeColorEnabled)
|
||||||
|
{
|
||||||
|
updateCascadeColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_cascadeOpacityEnabled)
|
||||||
|
{
|
||||||
|
updateCascadeOpacity();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Node::addChild(Node *child, int zOrder)
|
void Node::addChild(Node *child, int zOrder)
|
||||||
|
@ -1418,135 +1434,158 @@ PhysicsBody* Node::getPhysicsBody() const
|
||||||
}
|
}
|
||||||
#endif //CC_USE_PHYSICS
|
#endif //CC_USE_PHYSICS
|
||||||
|
|
||||||
// NodeRGBA
|
GLubyte Node::getOpacity(void) const
|
||||||
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
|
|
||||||
{
|
{
|
||||||
return _realOpacity;
|
return _realOpacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLubyte NodeRGBA::getDisplayedOpacity(void) const
|
GLubyte Node::getDisplayedOpacity(void) const
|
||||||
{
|
{
|
||||||
return _displayedOpacity;
|
return _displayedOpacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeRGBA::setOpacity(GLubyte opacity)
|
void Node::setOpacity(GLubyte opacity)
|
||||||
{
|
{
|
||||||
_displayedOpacity = _realOpacity = opacity;
|
_displayedOpacity = _realOpacity = opacity;
|
||||||
|
|
||||||
if (_cascadeOpacityEnabled)
|
updateCascadeOpacity();
|
||||||
{
|
|
||||||
GLubyte parentOpacity = 255;
|
|
||||||
RGBAProtocol* pParent = dynamic_cast<RGBAProtocol*>(_parent);
|
|
||||||
if (pParent && pParent->isCascadeOpacityEnabled())
|
|
||||||
{
|
|
||||||
parentOpacity = pParent->getDisplayedOpacity();
|
|
||||||
}
|
|
||||||
this->updateDisplayedOpacity(parentOpacity);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeRGBA::updateDisplayedOpacity(GLubyte parentOpacity)
|
void Node::updateDisplayedOpacity(GLubyte parentOpacity)
|
||||||
{
|
{
|
||||||
_displayedOpacity = _realOpacity * parentOpacity/255.0;
|
_displayedOpacity = _realOpacity * parentOpacity/255.0;
|
||||||
|
updateColor();
|
||||||
|
|
||||||
if (_cascadeOpacityEnabled)
|
if (_cascadeOpacityEnabled)
|
||||||
{
|
{
|
||||||
for(const auto &child : _children) {
|
for(auto child : _children){
|
||||||
RGBAProtocol* item = dynamic_cast<RGBAProtocol*>(child);
|
child->updateDisplayedOpacity(_displayedOpacity);
|
||||||
if (item)
|
|
||||||
{
|
|
||||||
item->updateDisplayedOpacity(_displayedOpacity);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NodeRGBA::isCascadeOpacityEnabled(void) const
|
bool Node::isCascadeOpacityEnabled(void) const
|
||||||
{
|
{
|
||||||
return _cascadeOpacityEnabled;
|
return _cascadeOpacityEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeRGBA::setCascadeOpacityEnabled(bool cascadeOpacityEnabled)
|
void Node::setCascadeOpacityEnabled(bool cascadeOpacityEnabled)
|
||||||
{
|
{
|
||||||
|
if (_cascadeOpacityEnabled == cascadeOpacityEnabled)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
_cascadeOpacityEnabled = cascadeOpacityEnabled;
|
_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;
|
return _realColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Color3B& NodeRGBA::getDisplayedColor() const
|
const Color3B& Node::getDisplayedColor() const
|
||||||
{
|
{
|
||||||
return _displayedColor;
|
return _displayedColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeRGBA::setColor(const Color3B& color)
|
void Node::setColor(const Color3B& color)
|
||||||
{
|
{
|
||||||
_displayedColor = _realColor = color;
|
_displayedColor = _realColor = color;
|
||||||
|
|
||||||
if (_cascadeColorEnabled)
|
updateCascadeColor();
|
||||||
{
|
|
||||||
Color3B parentColor = Color3B::WHITE;
|
|
||||||
RGBAProtocol *parent = dynamic_cast<RGBAProtocol*>(_parent);
|
|
||||||
if (parent && parent->isCascadeColorEnabled())
|
|
||||||
{
|
|
||||||
parentColor = parent->getDisplayedColor();
|
|
||||||
}
|
|
||||||
|
|
||||||
updateDisplayedColor(parentColor);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeRGBA::updateDisplayedColor(const Color3B& parentColor)
|
void Node::updateDisplayedColor(const Color3B& parentColor)
|
||||||
{
|
{
|
||||||
_displayedColor.r = _realColor.r * parentColor.r/255.0;
|
_displayedColor.r = _realColor.r * parentColor.r/255.0;
|
||||||
_displayedColor.g = _realColor.g * parentColor.g/255.0;
|
_displayedColor.g = _realColor.g * parentColor.g/255.0;
|
||||||
_displayedColor.b = _realColor.b * parentColor.b/255.0;
|
_displayedColor.b = _realColor.b * parentColor.b/255.0;
|
||||||
|
updateColor();
|
||||||
|
|
||||||
if (_cascadeColorEnabled)
|
if (_cascadeColorEnabled)
|
||||||
{
|
{
|
||||||
for(const auto &child : _children) {
|
for(const auto &child : _children){
|
||||||
RGBAProtocol *item = dynamic_cast<RGBAProtocol*>(child);
|
child->updateDisplayedColor(_displayedColor);
|
||||||
if (item)
|
|
||||||
{
|
|
||||||
item->updateDisplayedColor(_displayedColor);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NodeRGBA::isCascadeColorEnabled(void) const
|
bool Node::isCascadeColorEnabled(void) const
|
||||||
{
|
{
|
||||||
return _cascadeColorEnabled;
|
return _cascadeColorEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeRGBA::setCascadeColorEnabled(bool cascadeColorEnabled)
|
void Node::setCascadeColorEnabled(bool cascadeColorEnabled)
|
||||||
{
|
{
|
||||||
|
if (_cascadeColorEnabled == cascadeColorEnabled)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
_cascadeColorEnabled = cascadeColorEnabled;
|
_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
|
NS_CC_END
|
||||||
|
|
|
@ -48,7 +48,6 @@ class GridBase;
|
||||||
class Point;
|
class Point;
|
||||||
class Touch;
|
class Touch;
|
||||||
class Action;
|
class Action;
|
||||||
class RGBAProtocol;
|
|
||||||
class LabelProtocol;
|
class LabelProtocol;
|
||||||
class Scheduler;
|
class Scheduler;
|
||||||
class ActionManager;
|
class ActionManager;
|
||||||
|
@ -1395,6 +1394,24 @@ public:
|
||||||
|
|
||||||
#endif
|
#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:
|
protected:
|
||||||
// Nodes should be created using create();
|
// Nodes should be created using create();
|
||||||
Node();
|
Node();
|
||||||
|
@ -1413,6 +1430,12 @@ protected:
|
||||||
/// Convert cocos2d coordinates to UI windows coordinate.
|
/// Convert cocos2d coordinates to UI windows coordinate.
|
||||||
Point convertToWindowSpace(const Point& nodePoint) const;
|
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
|
float _rotationX; ///< rotation angle on x-axis
|
||||||
float _rotationY; ///< rotation angle on y-axis
|
float _rotationY; ///< rotation angle on y-axis
|
||||||
|
@ -1485,6 +1508,14 @@ protected:
|
||||||
PhysicsBody* _physicsBody; ///< the physicsBody the node have
|
PhysicsBody* _physicsBody; ///< the physicsBody the node have
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// opacity controls
|
||||||
|
GLubyte _displayedOpacity;
|
||||||
|
GLubyte _realOpacity;
|
||||||
|
Color3B _displayedColor;
|
||||||
|
Color3B _realColor;
|
||||||
|
bool _cascadeColorEnabled;
|
||||||
|
bool _cascadeOpacityEnabled;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CC_DISALLOW_COPY_AND_ASSIGN(Node);
|
CC_DISALLOW_COPY_AND_ASSIGN(Node);
|
||||||
};
|
};
|
||||||
|
@ -1500,41 +1531,33 @@ private:
|
||||||
Opacity/Color propagates into children that conform to the RGBAProtocol if cascadeOpacity/cascadeColor is enabled.
|
Opacity/Color propagates into children that conform to the RGBAProtocol if cascadeOpacity/cascadeColor is enabled.
|
||||||
@since v2.1
|
@since v2.1
|
||||||
*/
|
*/
|
||||||
class CC_DLL NodeRGBA : public Node, public RGBAProtocol
|
class CC_DLL __NodeRGBA : public Node, public __RGBAProtocol
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// overrides
|
// overrides
|
||||||
virtual GLubyte getOpacity() const override;
|
virtual GLubyte getOpacity() const override { return Node::getOpacity(); }
|
||||||
virtual GLubyte getDisplayedOpacity() const override;
|
virtual GLubyte getDisplayedOpacity() const override { return Node::getDisplayedOpacity(); }
|
||||||
virtual void setOpacity(GLubyte opacity) override;
|
virtual void setOpacity(GLubyte opacity) override { return Node::setOpacity(opacity); }
|
||||||
virtual void updateDisplayedOpacity(GLubyte parentOpacity) override;
|
virtual void updateDisplayedOpacity(GLubyte parentOpacity) override { return Node::updateDisplayedOpacity(parentOpacity); }
|
||||||
virtual bool isCascadeOpacityEnabled() const override;
|
virtual bool isCascadeOpacityEnabled() const override { return Node::isCascadeOpacityEnabled(); }
|
||||||
virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled) override;
|
virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled) override { return Node::setCascadeOpacityEnabled(cascadeOpacityEnabled); }
|
||||||
|
|
||||||
virtual const Color3B& getColor(void) const override;
|
virtual const Color3B& getColor(void) const override { return Node::getColor(); }
|
||||||
virtual const Color3B& getDisplayedColor() const override;
|
virtual const Color3B& getDisplayedColor() const override { return Node::getDisplayedColor(); }
|
||||||
virtual void setColor(const Color3B& color) override;
|
virtual void setColor(const Color3B& color) override { return Node::setColor(color); }
|
||||||
virtual void updateDisplayedColor(const Color3B& parentColor) override;
|
virtual void updateDisplayedColor(const Color3B& parentColor) override { return Node::updateDisplayedColor(parentColor); }
|
||||||
virtual bool isCascadeColorEnabled() const override;
|
virtual bool isCascadeColorEnabled() const override { return Node::isCascadeColorEnabled(); }
|
||||||
virtual void setCascadeColorEnabled(bool cascadeColorEnabled) override;
|
virtual void setCascadeColorEnabled(bool cascadeColorEnabled) override { return Node::setCascadeColorEnabled(cascadeColorEnabled); }
|
||||||
|
|
||||||
virtual void setOpacityModifyRGB(bool bValue) override {CC_UNUSED_PARAM(bValue);};
|
virtual void setOpacityModifyRGB(bool bValue) override { return Node::setOpacityModifyRGB(bValue); }
|
||||||
virtual bool isOpacityModifyRGB() const override { return false; };
|
virtual bool isOpacityModifyRGB() const override { return Node::isOpacityModifyRGB(); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
NodeRGBA();
|
__NodeRGBA();
|
||||||
virtual ~NodeRGBA();
|
virtual ~__NodeRGBA() {}
|
||||||
virtual bool init();
|
|
||||||
|
|
||||||
GLubyte _displayedOpacity;
|
|
||||||
GLubyte _realOpacity;
|
|
||||||
Color3B _displayedColor;
|
|
||||||
Color3B _realColor;
|
|
||||||
bool _cascadeColorEnabled;
|
|
||||||
bool _cascadeOpacityEnabled;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CC_DISALLOW_COPY_AND_ASSIGN(NodeRGBA);
|
CC_DISALLOW_COPY_AND_ASSIGN(__NodeRGBA);
|
||||||
};
|
};
|
||||||
|
|
||||||
// end of base_node group
|
// end of base_node group
|
||||||
|
|
|
@ -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
|
// Interval
|
||||||
|
|
||||||
///
|
///
|
||||||
|
|
|
@ -43,7 +43,7 @@ NS_CC_BEGIN
|
||||||
The progress can be Radial, Horizontal or vertical.
|
The progress can be Radial, Horizontal or vertical.
|
||||||
@since v0.99.1
|
@since v0.99.1
|
||||||
*/
|
*/
|
||||||
class CC_DLL ProgressTimer : public NodeRGBA
|
class CC_DLL ProgressTimer : public Node
|
||||||
#ifdef EMSCRIPTEN
|
#ifdef EMSCRIPTEN
|
||||||
, public GLBufferedNode
|
, public GLBufferedNode
|
||||||
#endif // EMSCRIPTEN
|
#endif // EMSCRIPTEN
|
||||||
|
@ -111,10 +111,6 @@ public:
|
||||||
// Overrides
|
// Overrides
|
||||||
virtual void draw(void) override;
|
virtual void draw(void) override;
|
||||||
void setAnchorPoint(const Point& anchorPoint) 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:
|
protected:
|
||||||
/**
|
/**
|
||||||
|
@ -137,7 +133,7 @@ protected:
|
||||||
void updateProgress(void);
|
void updateProgress(void);
|
||||||
void updateBar(void);
|
void updateBar(void);
|
||||||
void updateRadial(void);
|
void updateRadial(void);
|
||||||
void updateColor(void);
|
virtual void updateColor(void) override;
|
||||||
Point boundaryTexCoord(char index);
|
Point boundaryTexCoord(char index);
|
||||||
|
|
||||||
Type _type;
|
Type _type;
|
||||||
|
|
|
@ -35,10 +35,10 @@ NS_CC_BEGIN
|
||||||
/**
|
/**
|
||||||
* RGBA protocol that affects Node's color and opacity
|
* RGBA protocol that affects Node's color and opacity
|
||||||
*/
|
*/
|
||||||
class CC_DLL RGBAProtocol
|
class CC_DLL __RGBAProtocol
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~RGBAProtocol() {}
|
virtual ~__RGBAProtocol() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Changes the color with R,G,B bytes
|
* Changes the color with R,G,B bytes
|
||||||
|
|
|
@ -222,7 +222,7 @@ bool Sprite::initWithSpriteFrame(SpriteFrame *spriteFrame)
|
||||||
// designated initializer
|
// designated initializer
|
||||||
bool Sprite::initWithTexture(Texture2D *texture, const Rect& rect, bool rotated)
|
bool Sprite::initWithTexture(Texture2D *texture, const Rect& rect, bool rotated)
|
||||||
{
|
{
|
||||||
if (NodeRGBA::init())
|
if (Node::init())
|
||||||
{
|
{
|
||||||
_batchNode = nullptr;
|
_batchNode = nullptr;
|
||||||
|
|
||||||
|
@ -1075,20 +1075,6 @@ void Sprite::updateColor(void)
|
||||||
// do nothing
|
// 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)
|
void Sprite::setOpacityModifyRGB(bool modify)
|
||||||
{
|
{
|
||||||
if (_opacityModifyRGB != modify)
|
if (_opacityModifyRGB != modify)
|
||||||
|
@ -1103,20 +1089,6 @@ bool Sprite::isOpacityModifyRGB(void) const
|
||||||
return _opacityModifyRGB;
|
return _opacityModifyRGB;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sprite::updateDisplayedColor(const Color3B& parentColor)
|
|
||||||
{
|
|
||||||
NodeRGBA::updateDisplayedColor(parentColor);
|
|
||||||
|
|
||||||
updateColor();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Sprite::updateDisplayedOpacity(GLubyte opacity)
|
|
||||||
{
|
|
||||||
NodeRGBA::updateDisplayedOpacity(opacity);
|
|
||||||
|
|
||||||
updateColor();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Frames
|
// Frames
|
||||||
|
|
||||||
void Sprite::setSpriteFrame(const std::string &spriteFrameName)
|
void Sprite::setSpriteFrame(const std::string &spriteFrameName)
|
||||||
|
|
|
@ -78,7 +78,7 @@ struct transformValues_;
|
||||||
*
|
*
|
||||||
* The default anchorPoint in Sprite is (0.5, 0.5).
|
* 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:
|
public:
|
||||||
|
|
||||||
|
@ -426,16 +426,8 @@ public:
|
||||||
virtual void setVisible(bool bVisible) override;
|
virtual void setVisible(bool bVisible) override;
|
||||||
virtual void updateQuadVertices();
|
virtual void updateQuadVertices();
|
||||||
virtual void draw(void) override;
|
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 void setOpacityModifyRGB(bool modify) override;
|
||||||
virtual bool isOpacityModifyRGB(void) const override;
|
virtual bool isOpacityModifyRGB(void) const override;
|
||||||
virtual void updateDisplayedOpacity(GLubyte parentOpacity) override;
|
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -497,7 +497,7 @@ void CCBAnimationManager::setAnimatedProperty(const std::string& propName, Node
|
||||||
else if (propName == "opacity")
|
else if (propName == "opacity")
|
||||||
{
|
{
|
||||||
unsigned char opacity = value.asByte();
|
unsigned char opacity = value.asByte();
|
||||||
(dynamic_cast<RGBAProtocol*>(pNode))->setOpacity(opacity);
|
pNode->setOpacity(opacity);
|
||||||
}
|
}
|
||||||
else if (propName == "displayFrame")
|
else if (propName == "displayFrame")
|
||||||
{
|
{
|
||||||
|
@ -509,7 +509,7 @@ void CCBAnimationManager::setAnimatedProperty(const std::string& propName, Node
|
||||||
unsigned char r = c["r"].asByte();
|
unsigned char r = c["r"].asByte();
|
||||||
unsigned char g = c["g"].asByte();
|
unsigned char g = c["g"].asByte();
|
||||||
unsigned char b = c["b"].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")
|
else if (propName == "visible")
|
||||||
{
|
{
|
||||||
|
|
|
@ -67,7 +67,7 @@ CC_DEPRECATED_ATTRIBUTE typedef Armature CCArmature;
|
||||||
CC_DEPRECATED_ATTRIBUTE typedef ArmatureDataManager CCArmatureDataManager;
|
CC_DEPRECATED_ATTRIBUTE typedef ArmatureDataManager CCArmatureDataManager;
|
||||||
CC_DEPRECATED_ATTRIBUTE typedef TweenType CCTweenType;
|
CC_DEPRECATED_ATTRIBUTE typedef TweenType CCTweenType;
|
||||||
|
|
||||||
class Armature : public cocos2d::NodeRGBA, public cocos2d::BlendProtocol
|
class Armature : public cocos2d::Node, public cocos2d::BlendProtocol
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -263,37 +263,22 @@ void CCBone::setBlendFunc(const BlendFunc& blendFunc)
|
||||||
void Bone::updateDisplayedColor(const Color3B &parentColor)
|
void Bone::updateDisplayedColor(const Color3B &parentColor)
|
||||||
{
|
{
|
||||||
_realColor = Color3B(255, 255, 255);
|
_realColor = Color3B(255, 255, 255);
|
||||||
NodeRGBA::updateDisplayedColor(parentColor);
|
Node::updateDisplayedColor(parentColor);
|
||||||
updateColor();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bone::updateDisplayedOpacity(GLubyte parentOpacity)
|
void Bone::updateDisplayedOpacity(GLubyte parentOpacity)
|
||||||
{
|
{
|
||||||
_realOpacity = 255;
|
_realOpacity = 255;
|
||||||
NodeRGBA::updateDisplayedOpacity(parentOpacity);
|
Node::updateDisplayedOpacity(parentOpacity);
|
||||||
updateColor();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Bone::setColor(const Color3B& color)
|
|
||||||
{
|
|
||||||
NodeRGBA::setColor(color);
|
|
||||||
updateColor();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Bone::setOpacity(GLubyte opacity)
|
|
||||||
{
|
|
||||||
NodeRGBA::setOpacity(opacity);
|
|
||||||
updateColor();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bone::updateColor()
|
void Bone::updateColor()
|
||||||
{
|
{
|
||||||
Node *display = _displayManager->getDisplayRenderNode();
|
Node *display = _displayManager->getDisplayRenderNode();
|
||||||
RGBAProtocol *protocol = dynamic_cast<RGBAProtocol *>(display);
|
if(display != nullptr)
|
||||||
if(protocol != nullptr)
|
|
||||||
{
|
{
|
||||||
protocol->setColor(Color3B(_displayedColor.r * _tweenData->r / 255, _displayedColor.g * _tweenData->g / 255, _displayedColor.b * _tweenData->b / 255));
|
display->setColor(Color3B(_displayedColor.r * _tweenData->r / 255, _displayedColor.g * _tweenData->g / 255, _displayedColor.b * _tweenData->b / 255));
|
||||||
protocol->setOpacity(_displayedOpacity * _tweenData->a / 255);
|
display->setOpacity(_displayedOpacity * _tweenData->a / 255);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ namespace cocostudio {
|
||||||
|
|
||||||
class Armature;
|
class Armature;
|
||||||
|
|
||||||
class Bone : public cocos2d::NodeRGBA
|
class Bone : public cocos2d::Node
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
|
@ -134,11 +134,8 @@ public:
|
||||||
void updateDisplayedColor(const cocos2d::Color3B &parentColor) override;
|
void updateDisplayedColor(const cocos2d::Color3B &parentColor) override;
|
||||||
void updateDisplayedOpacity(GLubyte parentOpacity) 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
|
//! Update color to render display
|
||||||
void updateColor();
|
virtual void updateColor() override;
|
||||||
|
|
||||||
//! Update zorder
|
//! Update zorder
|
||||||
void updateZOrder();
|
void updateZOrder();
|
||||||
|
|
|
@ -297,11 +297,8 @@ void DisplayManager::setCurrentDecorativeDisplay(DecorativeDisplay *decoDisplay)
|
||||||
particle->resetSystem();
|
particle->resetSystem();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RGBAProtocol *rgbaProtocaol = dynamic_cast<RGBAProtocol *>(_displayRenderNode))
|
_displayRenderNode->setColor(_bone->getDisplayedColor());
|
||||||
{
|
_displayRenderNode->setOpacity(_bone->getDisplayedOpacity());
|
||||||
rgbaProtocaol->setColor(_bone->getDisplayedColor());
|
|
||||||
rgbaProtocaol->setOpacity(_bone->getDisplayedOpacity());
|
|
||||||
}
|
|
||||||
|
|
||||||
_displayRenderNode->retain();
|
_displayRenderNode->retain();
|
||||||
_displayRenderNode->setVisible(_visible);
|
_displayRenderNode->setVisible(_visible);
|
||||||
|
|
|
@ -35,7 +35,7 @@ namespace spine {
|
||||||
/**
|
/**
|
||||||
Draws a skeleton.
|
Draws a skeleton.
|
||||||
*/
|
*/
|
||||||
class CCSkeleton: public cocos2d::NodeRGBA, public cocos2d::BlendProtocol {
|
class CCSkeleton: public cocos2d::Node, public cocos2d::BlendProtocol {
|
||||||
public:
|
public:
|
||||||
static CCSkeleton* createWithData (SkeletonData* skeletonData, bool ownsSkeletonData = false);
|
static CCSkeleton* createWithData (SkeletonData* skeletonData, bool ownsSkeletonData = false);
|
||||||
static CCSkeleton* createWithFile (const char* skeletonDataFile, Atlas* atlas, float scale = 1);
|
static CCSkeleton* createWithFile (const char* skeletonDataFile, Atlas* atlas, float scale = 1);
|
||||||
|
|
|
@ -78,12 +78,8 @@ bool UILayout::init()
|
||||||
initRenderer();
|
initRenderer();
|
||||||
_renderer->retain();
|
_renderer->retain();
|
||||||
_renderer->setZOrder(_widgetZOrder);
|
_renderer->setZOrder(_widgetZOrder);
|
||||||
cocos2d::RGBAProtocol* renderRGBA = dynamic_cast<cocos2d::RGBAProtocol*>(_renderer);
|
_renderer->setCascadeColorEnabled(false);
|
||||||
if (renderRGBA)
|
_renderer->setCascadeOpacityEnabled(false);
|
||||||
{
|
|
||||||
renderRGBA->setCascadeColorEnabled(false);
|
|
||||||
renderRGBA->setCascadeOpacityEnabled(false);
|
|
||||||
}
|
|
||||||
ignoreContentAdaptWithSize(false);
|
ignoreContentAdaptWithSize(false);
|
||||||
setSize(cocos2d::Size::ZERO);
|
setSize(cocos2d::Size::ZERO);
|
||||||
setBright(true);
|
setBright(true);
|
||||||
|
@ -428,11 +424,7 @@ void UILayout::setColor(const cocos2d::Color3B &color)
|
||||||
UIWidget::setColor(color);
|
UIWidget::setColor(color);
|
||||||
if (_backGroundImage)
|
if (_backGroundImage)
|
||||||
{
|
{
|
||||||
cocos2d::RGBAProtocol* rgbap = dynamic_cast<cocos2d::RGBAProtocol*>(_backGroundImage);
|
_backGroundImage->setColor(color);
|
||||||
if (rgbap)
|
|
||||||
{
|
|
||||||
rgbap->setColor(color);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -441,11 +433,7 @@ void UILayout::setOpacity(int opacity)
|
||||||
UIWidget::setOpacity(opacity);
|
UIWidget::setOpacity(opacity);
|
||||||
if (_backGroundImage)
|
if (_backGroundImage)
|
||||||
{
|
{
|
||||||
cocos2d::RGBAProtocol* rgbap = dynamic_cast<cocos2d::RGBAProtocol*>(_backGroundImage);
|
_backGroundImage->setOpacity(opacity);
|
||||||
if (rgbap)
|
|
||||||
{
|
|
||||||
rgbap->setOpacity(opacity);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,6 @@ namespace gui {
|
||||||
|
|
||||||
#define DYNAMIC_CAST_CCBLENDPROTOCOL dynamic_cast<cocos2d::BlendProtocol*>(_renderer)
|
#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)
|
#define DYNAMIC_CAST_CCNODERGBA dynamic_cast<GUIRenderer*>(_renderer)
|
||||||
|
|
||||||
UIWidget::UIWidget():
|
UIWidget::UIWidget():
|
||||||
|
@ -111,12 +109,8 @@ bool UIWidget::init()
|
||||||
initRenderer();
|
initRenderer();
|
||||||
_renderer->retain();
|
_renderer->retain();
|
||||||
_renderer->setZOrder(_widgetZOrder);
|
_renderer->setZOrder(_widgetZOrder);
|
||||||
cocos2d::RGBAProtocol* renderRGBA = DYNAMIC_CAST_CCRGBAPROTOCOL;
|
_renderer->setCascadeColorEnabled(true);
|
||||||
if (renderRGBA)
|
_renderer->setCascadeOpacityEnabled(true);
|
||||||
{
|
|
||||||
renderRGBA->setCascadeColorEnabled(true);
|
|
||||||
renderRGBA->setCascadeOpacityEnabled(true);
|
|
||||||
}
|
|
||||||
setBright(true);
|
setBright(true);
|
||||||
ignoreContentAdaptWithSize(true);
|
ignoreContentAdaptWithSize(true);
|
||||||
_scheduler = cocos2d::Director::getInstance()->getScheduler();
|
_scheduler = cocos2d::Director::getInstance()->getScheduler();
|
||||||
|
@ -1050,78 +1044,42 @@ cocos2d::Action* UIWidget::getActionByTag(int tag)
|
||||||
|
|
||||||
void UIWidget::setColor(const cocos2d::Color3B &color)
|
void UIWidget::setColor(const cocos2d::Color3B &color)
|
||||||
{
|
{
|
||||||
cocos2d::RGBAProtocol* rgbap = DYNAMIC_CAST_CCRGBAPROTOCOL;
|
_renderer->setColor(color);
|
||||||
if (rgbap)
|
|
||||||
{
|
|
||||||
rgbap->setColor(color);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const cocos2d::Color3B& UIWidget::getColor()
|
const cocos2d::Color3B& UIWidget::getColor()
|
||||||
{
|
{
|
||||||
cocos2d::RGBAProtocol* rgbap = DYNAMIC_CAST_CCRGBAPROTOCOL;
|
return _renderer->getColor();
|
||||||
if (rgbap)
|
|
||||||
{
|
|
||||||
return rgbap->getColor();
|
|
||||||
}
|
|
||||||
return cocos2d::Color3B::WHITE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UIWidget::setOpacity(int opacity)
|
void UIWidget::setOpacity(int opacity)
|
||||||
{
|
{
|
||||||
cocos2d::RGBAProtocol* rgbap = DYNAMIC_CAST_CCRGBAPROTOCOL;
|
_renderer->setOpacity(opacity);
|
||||||
if (rgbap)
|
|
||||||
{
|
|
||||||
rgbap->setOpacity(opacity);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int UIWidget::getOpacity()
|
int UIWidget::getOpacity()
|
||||||
{
|
{
|
||||||
cocos2d::RGBAProtocol* rgbap = DYNAMIC_CAST_CCRGBAPROTOCOL;
|
return _renderer->getOpacity();
|
||||||
if (rgbap)
|
|
||||||
{
|
|
||||||
return rgbap->getOpacity();
|
|
||||||
}
|
|
||||||
return 255;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UIWidget::isCascadeOpacityEnabled()
|
bool UIWidget::isCascadeOpacityEnabled()
|
||||||
{
|
{
|
||||||
cocos2d::RGBAProtocol* rgbap = DYNAMIC_CAST_CCRGBAPROTOCOL;
|
return _renderer->isCascadeOpacityEnabled();
|
||||||
if (rgbap)
|
|
||||||
{
|
|
||||||
return rgbap->isCascadeOpacityEnabled();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UIWidget::setCascadeOpacityEnabled(bool cascadeOpacityEnabled)
|
void UIWidget::setCascadeOpacityEnabled(bool cascadeOpacityEnabled)
|
||||||
{
|
{
|
||||||
cocos2d::RGBAProtocol* rgbap = DYNAMIC_CAST_CCRGBAPROTOCOL;
|
_renderer->setCascadeOpacityEnabled(cascadeOpacityEnabled);
|
||||||
if (rgbap)
|
|
||||||
{
|
|
||||||
rgbap->setCascadeOpacityEnabled(cascadeOpacityEnabled);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UIWidget::isCascadeColorEnabled()
|
bool UIWidget::isCascadeColorEnabled()
|
||||||
{
|
{
|
||||||
cocos2d::RGBAProtocol* rgbap = DYNAMIC_CAST_CCRGBAPROTOCOL;
|
return _renderer->isCascadeColorEnabled();
|
||||||
if (rgbap)
|
|
||||||
{
|
|
||||||
return rgbap->isCascadeColorEnabled();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UIWidget::setCascadeColorEnabled(bool cascadeColorEnabled)
|
void UIWidget::setCascadeColorEnabled(bool cascadeColorEnabled)
|
||||||
{
|
{
|
||||||
cocos2d::RGBAProtocol* rgbap = DYNAMIC_CAST_CCRGBAPROTOCOL;
|
_renderer->setCascadeColorEnabled(cascadeColorEnabled);
|
||||||
if (rgbap)
|
|
||||||
{
|
|
||||||
rgbap->setCascadeColorEnabled(cascadeColorEnabled);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UIWidget::setBlendFunc(cocos2d::BlendFunc blendFunc)
|
void UIWidget::setBlendFunc(cocos2d::BlendFunc blendFunc)
|
||||||
|
@ -1309,7 +1267,7 @@ void GUIRenderer::visit()
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
cocos2d::NodeRGBA::visit();
|
cocos2d::Node::visit();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -994,7 +994,7 @@ protected:
|
||||||
* @js NA
|
* @js NA
|
||||||
* @lua NA
|
* @lua NA
|
||||||
*/
|
*/
|
||||||
class GUIRenderer : public cocos2d::NodeRGBA
|
class GUIRenderer : public cocos2d::Node
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GUIRenderer();
|
GUIRenderer();
|
||||||
|
|
|
@ -273,12 +273,20 @@ _G["CCFadeIn"] = DeprecatedClass.CCFadeIn()
|
||||||
|
|
||||||
--CCNodeRGBA class will be Deprecated,begin
|
--CCNodeRGBA class will be Deprecated,begin
|
||||||
function DeprecatedClass.CCNodeRGBA()
|
function DeprecatedClass.CCNodeRGBA()
|
||||||
deprecatedTip("CCNodeRGBA","cc.NodeRGBA")
|
deprecatedTip("CCNodeRGBA","cc.Node")
|
||||||
return cc.NodeRGBA
|
return cc.Node
|
||||||
end
|
end
|
||||||
_G["CCNodeRGBA"] = DeprecatedClass.CCNodeRGBA()
|
_G["CCNodeRGBA"] = DeprecatedClass.CCNodeRGBA()
|
||||||
--CCNodeRGBA class will be Deprecated,end
|
--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
|
--CCAnimationCache class will be Deprecated,begin
|
||||||
function DeprecatedClass.CCAnimationCache()
|
function DeprecatedClass.CCAnimationCache()
|
||||||
deprecatedTip("CCAnimationCache","cc.AnimationCache")
|
deprecatedTip("CCAnimationCache","cc.AnimationCache")
|
||||||
|
@ -1305,12 +1313,20 @@ _G["CCCamera"] = DeprecatedClass.CCCamera()
|
||||||
|
|
||||||
--CCLayerRGBA class will be Deprecated,begin
|
--CCLayerRGBA class will be Deprecated,begin
|
||||||
function DeprecatedClass.CCLayerRGBA()
|
function DeprecatedClass.CCLayerRGBA()
|
||||||
deprecatedTip("CCLayerRGBA","cc.LayerRGBA")
|
deprecatedTip("CCLayerRGBA","cc.Layer")
|
||||||
return cc.LayerRGBA
|
return cc.Layer
|
||||||
end
|
end
|
||||||
_G["CCLayerRGBA"] = DeprecatedClass.CCLayerRGBA()
|
_G["CCLayerRGBA"] = DeprecatedClass.CCLayerRGBA()
|
||||||
--CCLayerRGBA class will be Deprecated,end
|
--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
|
--CCBezierTo class will be Deprecated,begin
|
||||||
function DeprecatedClass.CCBezierTo()
|
function DeprecatedClass.CCBezierTo()
|
||||||
deprecatedTip("CCBezierTo","cc.BezierTo")
|
deprecatedTip("CCBezierTo","cc.BezierTo")
|
||||||
|
|
|
@ -224,13 +224,9 @@ void Control::setOpacityModifyRGB(bool bOpacityModifyRGB)
|
||||||
{
|
{
|
||||||
_isOpacityModifyRGB=bOpacityModifyRGB;
|
_isOpacityModifyRGB=bOpacityModifyRGB;
|
||||||
|
|
||||||
std::for_each(_children.begin(), _children.end(), [&](Node* obj){
|
for(auto child : _children){
|
||||||
RGBAProtocol* rgba = dynamic_cast<RGBAProtocol*>(obj);
|
child->setOpacityModifyRGB(bOpacityModifyRGB);
|
||||||
if (rgba)
|
|
||||||
{
|
|
||||||
rgba->setOpacityModifyRGB(bOpacityModifyRGB);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Control::isOpacityModifyRGB() const
|
bool Control::isOpacityModifyRGB() const
|
||||||
|
|
|
@ -62,7 +62,7 @@ class Invocation;
|
||||||
*
|
*
|
||||||
* To use the Control you have to subclass it.
|
* To use the Control you have to subclass it.
|
||||||
*/
|
*/
|
||||||
class Control : public LayerRGBA
|
class Control : public Layer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/** Kinds of possible events for the control objects. */
|
/** 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.");
|
CCASSERT(node != nullptr, "Label must not be nil.");
|
||||||
LabelProtocol* label = dynamic_cast<LabelProtocol*>(node);
|
LabelProtocol* label = dynamic_cast<LabelProtocol*>(node);
|
||||||
RGBAProtocol* rgbaLabel = dynamic_cast<RGBAProtocol*>(node);
|
|
||||||
CCASSERT(backgroundSprite != nullptr, "Background sprite must not be nil.");
|
CCASSERT(backgroundSprite != nullptr, "Background sprite must not be nil.");
|
||||||
CCASSERT(label != nullptr || rgbaLabel!=nullptr || backgroundSprite != nullptr, "");
|
CCASSERT(label != nullptr || backgroundSprite != nullptr, "");
|
||||||
|
|
||||||
_parentInited = true;
|
_parentInited = true;
|
||||||
|
|
||||||
|
@ -105,7 +104,7 @@ bool ControlButton::initWithLabelAndBackgroundSprite(Node* node, Scale9Sprite* b
|
||||||
// Initialize the dispatch table
|
// Initialize the dispatch table
|
||||||
|
|
||||||
setTitleForState(label->getString(), Control::State::NORMAL);
|
setTitleForState(label->getString(), Control::State::NORMAL);
|
||||||
setTitleColorForState(rgbaLabel->getColor(), Control::State::NORMAL);
|
setTitleColorForState(node->getColor(), Control::State::NORMAL);
|
||||||
setTitleLabelForState(node, Control::State::NORMAL);
|
setTitleLabelForState(node, Control::State::NORMAL);
|
||||||
setBackgroundSpriteForState(backgroundSprite, Control::State::NORMAL);
|
setBackgroundSpriteForState(backgroundSprite, Control::State::NORMAL);
|
||||||
|
|
||||||
|
@ -507,10 +506,9 @@ void ControlButton::needsLayout()
|
||||||
label->setString(_currentTitle);
|
label->setString(_currentTitle);
|
||||||
}
|
}
|
||||||
|
|
||||||
RGBAProtocol* rgbaLabel = dynamic_cast<RGBAProtocol*>(_titleLabel);
|
if (_titleLabel)
|
||||||
if (rgbaLabel)
|
|
||||||
{
|
{
|
||||||
rgbaLabel->setColor(_currentTitleColor);
|
_titleLabel->setColor(_currentTitleColor);
|
||||||
}
|
}
|
||||||
if (_titleLabel != nullptr)
|
if (_titleLabel != nullptr)
|
||||||
{
|
{
|
||||||
|
|
|
@ -700,14 +700,9 @@ void Scale9Sprite::setOpacityModifyRGB(bool var)
|
||||||
}
|
}
|
||||||
_opacityModifyRGB = var;
|
_opacityModifyRGB = var;
|
||||||
|
|
||||||
auto& children = _scale9Image->getChildren();
|
for(auto child : _scale9Image->getChildren()){
|
||||||
std::for_each(children.begin(), children.end(), [this](Node* child){
|
child->setOpacityModifyRGB(_opacityModifyRGB);
|
||||||
RGBAProtocol* rgba = dynamic_cast<RGBAProtocol*>(child);
|
|
||||||
if (rgba)
|
|
||||||
{
|
|
||||||
rgba->setOpacityModifyRGB(_opacityModifyRGB);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Scale9Sprite::isOpacityModifyRGB() const
|
bool Scale9Sprite::isOpacityModifyRGB() const
|
||||||
|
@ -788,21 +783,11 @@ void Scale9Sprite::setColor(const Color3B& color)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeRGBA::setColor(color);
|
Node::setColor(color);
|
||||||
|
|
||||||
auto& children = _scale9Image->getChildren();
|
for(auto child : _scale9Image->getChildren()){
|
||||||
std::for_each(children.begin(), children.end(), [&color](Node* child){
|
child->setColor(color);
|
||||||
RGBAProtocol* rgba = dynamic_cast<RGBAProtocol*>(child);
|
|
||||||
if (rgba)
|
|
||||||
{
|
|
||||||
rgba->setColor(color);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const Color3B& Scale9Sprite::getColor() const
|
|
||||||
{
|
|
||||||
return _realColor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scale9Sprite::setOpacity(GLubyte opacity)
|
void Scale9Sprite::setOpacity(GLubyte opacity)
|
||||||
|
@ -811,21 +796,11 @@ void Scale9Sprite::setOpacity(GLubyte opacity)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
NodeRGBA::setOpacity(opacity);
|
Node::setOpacity(opacity);
|
||||||
|
|
||||||
auto& children = _scale9Image->getChildren();
|
for(auto child : _scale9Image->getChildren()){
|
||||||
std::for_each(children.begin(), children.end(), [&opacity](Node* child){
|
child->setOpacity(opacity);
|
||||||
RGBAProtocol* rgba = dynamic_cast<RGBAProtocol*>(child);
|
|
||||||
if (rgba)
|
|
||||||
{
|
|
||||||
rgba->setOpacity(opacity);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
GLubyte Scale9Sprite::getOpacity() const
|
|
||||||
{
|
|
||||||
return _realOpacity;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scale9Sprite::updateDisplayedColor(const cocos2d::Color3B &parentColor)
|
void Scale9Sprite::updateDisplayedColor(const cocos2d::Color3B &parentColor)
|
||||||
|
@ -834,16 +809,11 @@ void Scale9Sprite::updateDisplayedColor(const cocos2d::Color3B &parentColor)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
NodeRGBA::updateDisplayedColor(parentColor);
|
Node::updateDisplayedColor(parentColor);
|
||||||
|
|
||||||
auto& children = _scale9Image->getChildren();
|
for(auto child : _scale9Image->getChildren()){
|
||||||
std::for_each(children.begin(), children.end(), [&parentColor](Node* child){
|
child->updateDisplayedColor(parentColor);
|
||||||
RGBAProtocol* rgba = dynamic_cast<RGBAProtocol*>(child);
|
|
||||||
if (rgba)
|
|
||||||
{
|
|
||||||
rgba->updateDisplayedColor(parentColor);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scale9Sprite::updateDisplayedOpacity(GLubyte parentOpacity)
|
void Scale9Sprite::updateDisplayedOpacity(GLubyte parentOpacity)
|
||||||
|
@ -852,16 +822,11 @@ void Scale9Sprite::updateDisplayedOpacity(GLubyte parentOpacity)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
NodeRGBA::updateDisplayedOpacity(parentOpacity);
|
Node::updateDisplayedOpacity(parentOpacity);
|
||||||
|
|
||||||
auto& children = _scale9Image->getChildren();
|
for(auto child : _scale9Image->getChildren()){
|
||||||
std::for_each(children.begin(), children.end(), [&parentOpacity](Node* child){
|
child->updateDisplayedOpacity(parentOpacity);
|
||||||
RGBAProtocol* rgba = dynamic_cast<RGBAProtocol*>(child);
|
|
||||||
if (rgba)
|
|
||||||
{
|
|
||||||
rgba->updateDisplayedOpacity(parentOpacity);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_CC_EXT_END
|
NS_CC_EXT_END
|
||||||
|
|
|
@ -50,7 +50,7 @@ NS_CC_EXT_BEGIN
|
||||||
*
|
*
|
||||||
* @see http://yannickloriot.com/library/ios/cccontrolextension/Classes/CCScale9Sprite.html
|
* @see http://yannickloriot.com/library/ios/cccontrolextension/Classes/CCScale9Sprite.html
|
||||||
*/
|
*/
|
||||||
class Scale9Sprite : public NodeRGBA
|
class Scale9Sprite : public Node
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
|
@ -262,9 +262,7 @@ public:
|
||||||
virtual void setOpacityModifyRGB(bool bValue) override;
|
virtual void setOpacityModifyRGB(bool bValue) override;
|
||||||
virtual bool isOpacityModifyRGB(void) const override;
|
virtual bool isOpacityModifyRGB(void) const override;
|
||||||
virtual void setOpacity(GLubyte opacity) override;
|
virtual void setOpacity(GLubyte opacity) override;
|
||||||
virtual GLubyte getOpacity() const override;
|
|
||||||
virtual void setColor(const Color3B& color) override;
|
virtual void setColor(const Color3B& color) override;
|
||||||
virtual const Color3B& getColor() const override;
|
|
||||||
virtual void updateDisplayedOpacity(GLubyte parentOpacity) override;
|
virtual void updateDisplayedOpacity(GLubyte parentOpacity) override;
|
||||||
virtual void updateDisplayedColor(const Color3B& parentColor) override;
|
virtual void updateDisplayedColor(const Color3B& parentColor) override;
|
||||||
|
|
||||||
|
|
|
@ -644,7 +644,7 @@ void S9CascadeOpacityAndColor::onEnter()
|
||||||
auto winSize = Director::getInstance()->getWinSize();
|
auto winSize = Director::getInstance()->getWinSize();
|
||||||
float x = winSize.width / 2;
|
float x = winSize.width / 2;
|
||||||
float y = 0 + (winSize.height / 2);
|
float y = 0 + (winSize.height / 2);
|
||||||
auto rgba = LayerRGBA::create();
|
auto rgba = Layer::create();
|
||||||
rgba->setCascadeColorEnabled(true);
|
rgba->setCascadeColorEnabled(true);
|
||||||
rgba->setCascadeOpacityEnabled(true);
|
rgba->setCascadeOpacityEnabled(true);
|
||||||
this->addChild(rgba);
|
this->addChild(rgba);
|
||||||
|
@ -672,7 +672,7 @@ void S9CascadeOpacityAndColor::onEnter()
|
||||||
|
|
||||||
std::string S9CascadeOpacityAndColor::title() const
|
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
|
std::string S9CascadeOpacityAndColor::subtitle() const
|
||||||
|
|
|
@ -22,7 +22,9 @@ static std::function<Layer*()> createFunctions[] = {
|
||||||
CL(LayerIgnoreAnchorPointPos),
|
CL(LayerIgnoreAnchorPointPos),
|
||||||
CL(LayerIgnoreAnchorPointRot),
|
CL(LayerIgnoreAnchorPointRot),
|
||||||
CL(LayerIgnoreAnchorPointScale),
|
CL(LayerIgnoreAnchorPointScale),
|
||||||
CL(LayerExtendedBlendOpacityTest)
|
CL(LayerExtendedBlendOpacityTest),
|
||||||
|
CL(LayerBug3162A),
|
||||||
|
CL(LayerBug3162B),
|
||||||
};
|
};
|
||||||
|
|
||||||
static int sceneIdx=-1;
|
static int sceneIdx=-1;
|
||||||
|
@ -112,12 +114,8 @@ void LayerTest::backCallback(Object* sender)
|
||||||
|
|
||||||
static void setEnableRecursiveCascading(Node* node, bool enable)
|
static void setEnableRecursiveCascading(Node* node, bool enable)
|
||||||
{
|
{
|
||||||
auto rgba = dynamic_cast<RGBAProtocol*>(node);
|
node->setCascadeColorEnabled(enable);
|
||||||
if (rgba)
|
node->setCascadeOpacityEnabled(enable);
|
||||||
{
|
|
||||||
rgba->setCascadeColorEnabled(enable);
|
|
||||||
rgba->setCascadeOpacityEnabled(enable);
|
|
||||||
}
|
|
||||||
|
|
||||||
auto& children = node->getChildren();
|
auto& children = node->getChildren();
|
||||||
std::for_each(children.begin(), children.end(), [enable](Node* child){
|
std::for_each(children.begin(), children.end(), [enable](Node* child){
|
||||||
|
@ -131,7 +129,7 @@ void LayerTestCascadingOpacityA::onEnter()
|
||||||
LayerTest::onEnter();
|
LayerTest::onEnter();
|
||||||
|
|
||||||
auto s = Director::getInstance()->getWinSize();
|
auto s = Director::getInstance()->getWinSize();
|
||||||
auto layer1 = LayerRGBA::create();
|
auto layer1 = Layer::create();
|
||||||
|
|
||||||
auto sister1 = Sprite::create("Images/grossinis_sister1.png");
|
auto sister1 = Sprite::create("Images/grossinis_sister1.png");
|
||||||
auto sister2 = Sprite::create("Images/grossinis_sister2.png");
|
auto sister2 = Sprite::create("Images/grossinis_sister2.png");
|
||||||
|
@ -170,7 +168,7 @@ void LayerTestCascadingOpacityA::onEnter()
|
||||||
|
|
||||||
std::string LayerTestCascadingOpacityA::title() const
|
std::string LayerTestCascadingOpacityA::title() const
|
||||||
{
|
{
|
||||||
return "LayerRGBA: cascading opacity";
|
return "Layer: cascading opacity";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -284,7 +282,7 @@ void LayerTestCascadingColorA::onEnter()
|
||||||
LayerTest::onEnter();
|
LayerTest::onEnter();
|
||||||
|
|
||||||
auto s = Director::getInstance()->getWinSize();
|
auto s = Director::getInstance()->getWinSize();
|
||||||
auto layer1 = LayerRGBA::create();
|
auto layer1 = Layer::create();
|
||||||
|
|
||||||
auto sister1 = Sprite::create("Images/grossinis_sister1.png");
|
auto sister1 = Sprite::create("Images/grossinis_sister1.png");
|
||||||
auto sister2 = Sprite::create("Images/grossinis_sister2.png");
|
auto sister2 = Sprite::create("Images/grossinis_sister2.png");
|
||||||
|
@ -326,7 +324,7 @@ void LayerTestCascadingColorA::onEnter()
|
||||||
|
|
||||||
std::string LayerTestCascadingColorA::title() const
|
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";
|
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;
|
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
|
class LayerTestScene : public TestScene
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -62,9 +62,9 @@ end
|
||||||
|
|
||||||
-- LayerTestCascadingOpacityA
|
-- LayerTestCascadingOpacityA
|
||||||
local function LayerTestCascadingOpacityA()
|
local function LayerTestCascadingOpacityA()
|
||||||
local ret = createLayerDemoLayer("LayerRGBA: cascading opacity")
|
local ret = createLayerDemoLayer("Layer: cascading opacity")
|
||||||
local s = cc.Director:getInstance():getWinSize()
|
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 sister1 = cc.Sprite:create("Images/grossinis_sister1.png")
|
||||||
local sister2 = cc.Sprite:create("Images/grossinis_sister2.png")
|
local sister2 = cc.Sprite:create("Images/grossinis_sister2.png")
|
||||||
|
@ -165,10 +165,10 @@ end
|
||||||
|
|
||||||
-- LayerTestCascadingColorA
|
-- LayerTestCascadingColorA
|
||||||
local function LayerTestCascadingColorA()
|
local function LayerTestCascadingColorA()
|
||||||
local ret = createLayerDemoLayer("LayerRGBA: cascading color")
|
local ret = createLayerDemoLayer("Layer: cascading color")
|
||||||
|
|
||||||
local s = cc.Director:getInstance():getWinSize()
|
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 sister1 = cc.Sprite:create("Images/grossinis_sister1.png")
|
||||||
local sister2 = cc.Sprite:create("Images/grossinis_sister2.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
|
# 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*$".
|
# 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
|
classes_need_extend = Node Layer.* Sprite MenuItemFont Scene DrawNode
|
||||||
|
|
||||||
|
@ -126,7 +126,9 @@ rename_functions = SpriteFrameCache::[addSpriteFramesWithFile=addSpriteFrames ge
|
||||||
FileUtils::[loadFilenameLookupDictionaryFromFile=loadFilenameLookup]
|
FileUtils::[loadFilenameLookupDictionaryFromFile=loadFilenameLookup]
|
||||||
|
|
||||||
rename_classes = ParticleSystemQuad::ParticleSystem,
|
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?
|
# for all class names, should we remove something when registering in the target VM?
|
||||||
remove_prefix =
|
remove_prefix =
|
||||||
|
|
Loading…
Reference in New Issue