Cocos2d-x で開発をしていて、CCLabelTTFに縁取りをしたいと思って、
以下のように記述
CCLabelTTF* pLabel = CCLabelTTF::create(labelType.c_str(), GAME_FONT, 28);
// 影をつける
pLabel->enableShadow(CCSizeMake(4,-4),0.5,0.8,true);
// 縁取りをする
pLabel->enableStroke(ccGRAY,1.0,true);
cocos2d-x のバージョンは、cocos2d-x-2.2.3
iOS7だと、縁取りが反映されない。
ここに対処方法が乗ってた。
Stroking not working on CCLabelTTF in cocos2d-x ios in c++
これを参考に、以下のように修正しました。
修正前:
// actually draw the text in the context
// XXX: ios7 casting
[str drawInRect:CGRectMake(textOriginX, textOrigingY, textWidth, textHeight) withFont:font lineBreakMode:NSLineBreakByWordWrapping alignment:(NSTextAlignment)align];
修正後:
// actually draw the text in the context
// XXX: ios7 casting
[str drawInRect:CGRectMake(textOriginX, textOrigingY, textWidth, textHeight) withFont:font lineBreakMode:NSLineBreakByWordWrapping alignment:(NSTextAlignment)align];
// New Code Start
if(pInfo->hasStroke) {
CGContextSetTextDrawingMode(context, kCGTextStroke);
CGContextSetRGBFillColor(context, pInfo->strokeColorR, pInfo->strokeColorG, pInfo->strokeColorB,1);
CGContextSetLineWidth(context, pInfo->strokeSize);
[str drawInRect:CGRectMake(textOriginX, textOrigingY, textWidth, textHeight) withFont:font lineBreakMode:NSLineBreakByWordWrapping alignment:(NSTextAlignment)align];
}
//New Code End
試してませんが、以下のサイトの方法でも大丈夫かもです。