fix crash when sort children while label type is STRING_TEXTURE. since the only one child sprite is not add with batch mode

This commit is contained in:
bmanGH 2014-03-26 16:23:23 +08:00
parent 1328d1a898
commit 503fed5313
2 changed files with 11 additions and 0 deletions

View File

@ -786,6 +786,15 @@ void Label::addChild(Node * child, int zOrder/* =0 */, int tag/* =0 */)
CCASSERT(0, "addChild: is not supported on Label."); CCASSERT(0, "addChild: is not supported on Label.");
} }
void Label::sortAllChildren()
{
// fix crash when sort children while label type is STRING_TEXTURE
// because of the only one child sprite is not add with batch mode
if (_currentLabelType != LabelType::STRING_TEXTURE) {
SpriteBatchNode::sortAllChildren();
}
}
void Label::setLabelEffect(LabelEffect effect,const Color3B& effectColor) void Label::setLabelEffect(LabelEffect effect,const Color3B& effectColor)
{ {
switch (effect) switch (effect)

View File

@ -239,6 +239,8 @@ public:
virtual float getScaleY() const override; virtual float getScaleY() const override;
virtual void addChild(Node * child, int zOrder=0, int tag=0) override; virtual void addChild(Node * child, int zOrder=0, int tag=0) override;
virtual void sortAllChildren() override;
virtual std::string getDescription() const override; virtual std::string getDescription() const override;
virtual const Size& getContentSize() const override; virtual const Size& getContentSize() const override;