cocos2d::TransitionFade * utilities::XMLToTransitionFade(const tinyxml2::XMLElement *xmlElement, cocos2d::Scene * transiteTo)
{
	auto durationElement = xmlElement->FirstChildElement("Duration");
	assert(durationElement && "utilities::XMLToTransitionFade() the xml element has no duration element.");
	auto durationSec = durationElement->FloatAttribute("Value");

	auto color3BElement = xmlElement->FirstChildElement("Color3B");
	if (!color3BElement)
		return cocos2d::TransitionFade::create(durationSec, transiteTo);

	return cocos2d::TransitionFade::create(durationSec, transiteTo, XMLToColor3B(color3BElement));
}
Пример #2
0
	void setButtonTitlePropertiesWithXML(cocos2d::ui::Button * button, const tinyxml2::XMLElement * titlePropertiesElement)
	{
		if (!button || !titlePropertiesElement) {
			return;
		}

		if (const auto fontNameElement = titlePropertiesElement->FirstChildElement("FontName")) {
			button->setTitleFontName(fontNameElement->Attribute("Value"));
		}

		if (const auto fontSizeElement = titlePropertiesElement->FirstChildElement("FontSize")) {
			button->setTitleFontSize(fontSizeElement->FloatAttribute("Value"));
		}

		if (const auto colorElement = titlePropertiesElement->FirstChildElement("TitleColor")) {
			button->setTitleColor(XMLToColor3B(colorElement));
		}
	}