本文整理汇总了C++中LoadingBar::addChild方法的典型用法代码示例。如果您正苦于以下问题:C++ LoadingBar::addChild方法的具体用法?C++ LoadingBar::addChild怎么用?C++ LoadingBar::addChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LoadingBar
的用法示例。
在下文中一共展示了LoadingBar::addChild方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setPropsWithFlatBuffers
void LoadingBarReader::setPropsWithFlatBuffers(cocos2d::Node *node, const flatbuffers::Table *loadingBarOptions)
{
LoadingBar* loadingBar = static_cast<LoadingBar*>(node);
auto options = (LoadingBarOptions*)loadingBarOptions;
bool fileExist = false;
std::string errorFilePath = "";
auto imageFileNameDic = options->textureData();
int imageFileNameType = imageFileNameDic->resourceType();
std::string imageFileName = imageFileNameDic->path()->c_str();
switch (imageFileNameType)
{
case 0:
{
if (FileUtils::getInstance()->isFileExist(imageFileName))
{
fileExist = true;
}
else
{
errorFilePath = imageFileName;
fileExist = false;
}
break;
}
case 1:
{
std::string plist = imageFileNameDic->plistFile()->c_str();
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(imageFileName);
if (spriteFrame)
{
fileExist = true;
}
else
{
if (FileUtils::getInstance()->isFileExist(plist))
{
ValueMap value = FileUtils::getInstance()->getValueMapFromFile(plist);
ValueMap metadata = value["metadata"].asValueMap();
std::string textureFileName = metadata["textureFileName"].asString();
if (!FileUtils::getInstance()->isFileExist(textureFileName))
{
errorFilePath = textureFileName;
}
}
else
{
errorFilePath = plist;
}
fileExist = false;
}
break;
}
default:
break;
}
if (fileExist)
{
loadingBar->loadTexture(imageFileName, (Widget::TextureResType)imageFileNameType);
}
else
{
auto label = Label::create();
label->setString(__String::createWithFormat("%s missed", errorFilePath.c_str())->getCString());
loadingBar->addChild(label);
}
int direction = options->direction();
loadingBar->setDirection(LoadingBar::Direction(direction));
int percent = options->percent();
loadingBar->setPercent(percent);
auto widgetReader = WidgetReader::getInstance();
widgetReader->setPropsWithFlatBuffers(node, (Table*)options->widgetOptions());
}