bool HelloWorld::init()
{
if ( !Layer::init() )
{
return false;
}
Size visibleSize = Director::getInstance()->getVisibleSize();
Vec2 origin = Director::getInstance()->getVisibleOrigin();
Vector<Label *> vec;
auto label1=Label::create();
auto label2=Label::create();
label1->setString("Label 1");
label2->setString("Label 2");
label1->setSystemFontSize(50);
label2->setSystemFontSize(50);
vec.pushBack(label1);
vec.pushBack(label2);
int i=0;
for (auto label:vec) {
i++;
label->setPosition(Vec2(visibleSize.width/2,i*200));
addChild(label);
}
Map<std::string,Label*> map;
auto label3=Label::create();
auto label4=Label::create();
label3->setString("Label 3");
label4->setString("Label 4");
label3->setSystemFontSize(20);
label4->setSystemFontSize(20);
label3->setPosition(Vec2(visibleSize.width/4,100));
label4->setPosition(Vec2(visibleSize.width*3/4,visibleSize.height-100));
map.insert("label3",label3);
map.insert("label4",label4);
addChild(map.at("label3"));
addChild(map.at("label4"));
return true;
}