2016-08-07 6 views
1

私はcocos2d-x(C++)verを使用します。 3.8 on tvOS(Apple TV)カスタムカラーで中国語と日本語の文字を作成するには

中国語や日本語の文字を含むArial TTFフォントがなく、許容できるファイルサイズ(最大1MB)を持っていないため、TTFバージョンを使用したくありません。

Label::createWithSystemFont()を使用している場合、テキストの色を変更することはできません。少なくとも私はそれを変更する方法を見つけられませんでした。

auto *n = Label::createWithSystemFont("洗牌位置", font, fontSize, dimensions, hAlignment, vAlignment); 
n->setColor(Color3B::RED); 
n->setTextColor(Color4B::RED); 

これは黒のテキストを生成...

編集:私はあなたが私が怒っていると思うかもしれない何かを試してみた絶望的な状況では

。 しかし、どちらもうまくいきません。結果はまだ黒です。あなたはどのようにラベルの色を変更する方法を知っていますか?

Node* NodeFactory::colorizeLabel (Label *lbl, const Color3B& color) 
{ 
    auto *maskSprite = lbl; 

    CCRenderTexture * rt; 
     rt = CCRenderTexture::create(
            maskSprite->getContentSize().width*maskSprite->getScaleX(), 
            maskSprite->getContentSize().height*maskSprite->getScaleY() 
            , kCCTexture2DPixelFormat_RGBA8888 
     ); 
     maskSprite->setPosition(ccp(
            (maskSprite->getContentSize().width*maskSprite->getScaleX())/2, 
            (maskSprite->getContentSize().height*maskSprite->getScaleY())/2 
            ) 
           ); 


    //rt->begin(); 
    rt->beginWithClear(120, 120, 0, 0); 
    ((Node*)maskSprite)->visit(); 
    rt->end(); 

    Sprite *retval = Sprite::createWithTexture(rt->getSprite()->getTexture()); 
    retval->setColor(Color3B::WHITE); 
    //retval->setBlendFunc((ccBlendFunc) { GL_SRC_COLOR, GL_ONE }); 

    return retval; 
} 
+0

のように質問をupvoted ORIG

それは完全に有効なIMOですが、恥知らずの広告のために私ができるなら、アバターを下降させるでしょう:-)トピックについての:同じコードでTTFを使用し、ASCII文字を使用したカラー出力がテストされましたか?システムフォントが含まれているときに色を変更することができないようにすべき理由はありません。 – dlatikay

+0

はい、TTFは正常に動作します。システムフォント(incl.color)でなければならないため、システムフォントの色の変更が無効になっていることに注意してください。今、私はまともなTTFフォントを探しています:-( –

+0

既知の問題の修正点のようです "ラベル:システムフォントのストロークカラーがiOSで正しくありません"は、cocos2d-x-4.0alphaより前に存在しません... – dlatikay

答えて

0
tvOS上の色のシステムフォントのための

FOUNDソリューション: FIX:CCDevice-tvos.mm:

[str drawInRect:rect withAttributes:@{ NSFontAttributeName: font, NSParagraphStyleAttributeName:paragraphStyle }]; 

NEW:

[str drawInRect:rect withAttributes:@{ NSFontAttributeName: font, NSParagraphStyleAttributeName:paragraphStyle, 
    NSForegroundColorAttributeName:[UIColor colorWithRed:info->tintColorR green:info->tintColorG blue:info->tintColorB alpha:info->tintColorA] 
}]; 
関連する問題