2015-12-17 28 views
0

當我嘗試發佈的iOS遊戲到機器人的setColor(Color3B :: GREEN)不工作,字體顏色不來正確COCOS 2DX的setColor(Color3B :: GREEN)不工作

l_answer = Label::createWithTTF(label_config,str_numberStr); 
l_answer->setColor(Color3B::GREEN); 
l_answer->enableOutline(Color4B(0,0,0,255),255); 
l_answer->enableGlow(Color4B(0,0,0,225)); 
l_answer->setScale(0.0f); 

顏色字體不正確。

+0

「不正確」是什麼意思? – ajshort

+0

實際上,我希望我的標籤(字體)顏色應該變成深綠色,但默認情況下它會變成黑色。字體的顏色不會出現。 – anand

回答

0

您不能在標籤上設置多個效果。在enum class LabelEffect中定義的效果在ccTypes.h中,並且它們相互抵消。現在,您只能看到Glow效果,但如果換入enableOutline()and enableGlow(),則只會看到「輪廓」效果。
例如,對於代碼

Label* lbSomeText = Label::createWithTTF("sometext", "fonts/junegull_rg.ttf", 100); 
lbSomeText->setPosition(Vec2(winSize.width * 0.5f, winSize.height * 0.5f)); 
lbSomeText->setColor(230,110,180); // I set for more contrast with green 
lbSomeText->enableGlow(Color4B(0,0,0,255)); 
lbSomeText->enableOutline(Color4B(0,255,0,255), 15); 
this->addChild(lbSomeText); 

結果是:

outline

對於代碼

... 
lbSomeText->enableOutline(Color4B(0,255,0,255), 15); 
lbSomeText->enableGlow(Color4B(0,0,0,255)); 
... 

結果是:

enter image description here

接下來,如果你想看到GREEN的效果,你需要設置Color4B(r, g, b, alpha)Color4B(0, 255, 0, 255)。現在你有(0, 0, 0, 255),結果是BLACK顏色。例如,這裏是導致對其lbSomeText->enableGlow(Color4B(0,255,0,255));

enter image description here

正如你所看到的,有綠色和黑色泛着之間的差別不大,因爲你不能設置發光的寬度。所以,如果你需要更多的發光,更好的方法是從Photoshop等設計程序中的標籤文本中製作精靈,並在該程序中手動添加更多發光效果。
我希望我回答你的問題。現在您可以選擇最適合您的選項。