我想在CCLayerColor上添加Label,但我没有得到......
// on "init" you need to initialize your instance
bool SplashScreen::init()
{
//////////////////////////////
// 1. super init first
if ( !CCLayerColor::initWithColor(Colors::GetMainAccentColor4B()) )
{
return false;
}
auto visibleSize = Director::getInstance()->getVisibleSize();
auto origin = Director::getInstance()->getVisibleOrigin();
auto label1 = CCLabelTTF::create("Hello World", "Helvetica", 12,
CCSizeMake(245, 32), kCCTextAlignmentCenter);
this->addChild(label1, 1);
return true;
}
Colors :: GetMainAccentColor4B() - 工作正常 - 这是我的课,给我颜色
答案 0 :(得分:0)
试试这个
auto label = LabelTTF::create("Hello World", "Helvetica", 100, Size(245, 32), TextHAlignment::CENTER);
label->setPosition(Point(visibleSize.width * 0.5, visibleSize.height * 0.5));
this->addChild(label);
它应该在中心屏幕上绘制标签。不在cocos2d-x 3.0中使用已弃用的方法或类似CC LabelTTF的类。