现在的位置: 首页 > 综合 > 正文

cocos2d-x 标签加黑边和阴影

2018年05月17日 ⁄ 综合 ⁄ 共 815字 ⁄ 字号 评论关闭

出自:cocos2d-x testCpp

CCSize s = CCDirector::sharedDirector()->getWinSize();
    CCSize shadowOffset(5.0, 5.0);
    // font definition
    ccFontDefinition shadowTextDef;
    shadowTextDef.m_fontSize = 48;
    shadowTextDef.m_fontName = std::string(strFONT_BOLD_HELVETICA);
    // shadow
    shadowTextDef.m_shadow.m_shadowEnabled = false;
    shadowTextDef.m_shadow.m_shadowOffset  = shadowOffset;
    shadowTextDef.m_shadow.m_shadowOpacity = 1.0f;
    shadowTextDef.m_shadow.m_shadowBlur    = 0.5f;
    // stroke
    shadowTextDef.m_stroke.m_strokeEnabled = true;
    shadowTextDef.m_stroke.m_strokeColor   = ccBLACK;
    shadowTextDef.m_stroke.m_strokeSize    = 1.f;
    // font fill color
    shadowTextDef.m_fontFillColor   = ccRED;
    // label
    CCLabelTTF* fontShadow = CCLabelTTF::createWithFontDefinition("Shadow Only Red Text", shadowTextDef);
    fontShadow->setPosition(ccp(s.width * 0.5f, s.height * 0.5f));
    // add label to the scene
    this->addChild(fontShadow);

抱歉!评论已关闭.