Ejemplo n.º 1
0
void LoadFromBin::Load(const std::string& filepath, Symbol& complex)
{
	mm::LinearAllocator alloc;

	auto sym = s2s::NodeFactory::CreateSymFromBin(alloc, filepath);
	auto sym_src = dynamic_cast<s2s::ComplexSym*>(sym);

	sm::rect scissor;
	scissor.xmin = sym_src->scissor[0];
	scissor.ymin = sym_src->scissor[1];
	scissor.xmax = sym_src->scissor[2];
	scissor.ymax = sym_src->scissor[3];
	complex.SetScissor(scissor);

	auto dir = ee::FileHelper::GetFileDir(filepath);
	for (int i = 0; i < sym_src->children_n; ++i) 
	{
		auto& child = sym_src->children[i];
		auto child_path = ee::FileHelper::GetAbsolutePath(
			dir, child->GetCommon().GetFilepath());
		auto sym = ee::SymbolMgr::Instance()->FetchSymbol(child_path);
		auto spr = ee::SpriteFactory::Instance()->Create(sym);
		spr->Load(child);
		spr->SetVisible(true);
		complex.Add(spr);
	}
}
Ejemplo n.º 2
0
void LoadFromPSD::Load(const Json::Value& value, const std::string& dir, Symbol& complex)
{
	int w = value["document"]["width"].asInt(),
		h = value["document"]["height"].asInt();

	const Json::Value& cvalue = value["children"];
//	for (int i = 0, n = cvalue.size(); i < n; ++i) {
	for (int i = cvalue.size() - 1; i >= 0; --i) {
		auto spr = LoadItem(cvalue[i], dir, w, h);
		if (spr) {
			complex.Add(spr);
		}
	}
}