出自: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);