Beispiel #1
0
 void StatusLabel::setTextAndColor(std::string text, GemUtils::GemColor c)
 {
     if(bg)
         bg->removeFromParentAndCleanup(true);
     bg = GetSprite(ColorToStatusBG(c));
     bg->setAnchorPoint(ccp(0.5f, 0.5f));
     root->addChild(bg); // set zorder explicitly below text
     
     CCLabelBMFont* old = textLabel;
     
     textLabel = CCLabelBMFont::create(text.c_str(), ColorToStatusFont(c));
     textLabel->setAnchorPoint(ccp(0.5f, 0.5f));
     textLabel->setPosition(ccp(-3.0f, -1.5f));
     textLabel->setScale(contentScale()*0.9f);
     root->addChild(textLabel);
     
     root->setScale(0.0f);
     
     // COCOS2DX BUG: remove after new sprite batch is created
     // THIS is remedied by changing CC_ENABLE_GL_STATE_CACHE to 0
     // in ccConfig.h
     if(old)
         old->removeFromParentAndCleanup(true);
 }