本文整理汇总了C++中BackgroundLayer::load方法的典型用法代码示例。如果您正苦于以下问题:C++ BackgroundLayer::load方法的具体用法?C++ BackgroundLayer::load怎么用?C++ BackgroundLayer::load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BackgroundLayer
的用法示例。
在下文中一共展示了BackgroundLayer::load方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readBackgroundLayers
bool LevelReader::readBackgroundLayers(XMLElement* _property, LevelData& data) const
{
// we've found the property "backgroundlayers"
const char* textAttr = nullptr;
textAttr = _property->Attribute("value");
if (textAttr == nullptr)
{
g_logger->logError("LevelReader", "XML file could not be read, no value attribute found (map->properties->property->name=backgroundlayer).");
return false;
}
std::string backgroundLayerText = textAttr;
size_t pos = 0;
float distance = 0.f;
std::string backgroundLayer = "";
while ((pos = backgroundLayerText.find(",")) != std::string::npos)
{
distance = static_cast<float>(atof(backgroundLayerText.substr(0, pos).c_str()));
backgroundLayerText.erase(0, pos + 1);
if ((pos = backgroundLayerText.find(",")) != std::string::npos)
{
backgroundLayer = backgroundLayerText.substr(0, pos);
backgroundLayerText.erase(0, pos + 1);
}
else
{
backgroundLayer = backgroundLayerText;
backgroundLayerText.clear();
}
BackgroundLayer layer;
layer.load(backgroundLayer, distance);
data.backgroundLayers.push_back(layer);
}
return true;
}