在创建project后主要通过HelloWorldScene.ccp编辑界面,仿照默认生成的label可以自行添加定义label。
//此为默认生成 if (label == nullptr) { problemLoading("'fonts/Marker Felt.ttf'"); } else { // position the label on the center of the screen label->setPosition(Vec2(origin.x + visibleSize.width/2, origin.y + visibleSize.height - label->getContentSize().height)); // add the label as a child to this layer this->addChild(label, 1); }//此为自行添加 auto label1 = Label::createWithTTF("Mother fucker", "fonts/Marker Felt.ttf", 20); if (label1 == nullptr) { problemLoading("'fonts/Marker Felt.tff'"); } else { label1->setPosition(Vec2(origin.x + visibleSize.width/3, origin.y + visibleSize.height - label1->getContentSize().height)); this->addChild(label1, 2); } auto label = Label::createWithTTF("HELLOW WORLD", "fonts/Marker Felt.ttf", 24);
注意区分“=”与“==”。