// ---------------------------------------------------------- // public // ---------------------------------------------------------- public XTFrame GetFrame(string name) { if (this.m_frames == null) { XElement e = XTPListXML.GetSubElement(this.m_root, "frames/" + name); if (e == null) { return(null); } return(new XTFrame(name, e)); } XTFrame frame = null; if (!this.m_frames.TryGetValue(name, out frame)) { XElement e = XTPListXML.GetSubElement(this.m_root, "frames/" + name); if (e == null) { return(null); } frame = new XTFrame(name, e); this.m_frames[name] = frame; } return(frame); }
// 如果 Plist 文件不存在,则抛出 FileNotFoundException 异常 // 如果不是合法的 PList 文件,则抛出 XTInvalidPListFileException 异常 public static XTPListFile Create(string file, bool isCache = true) { XElement root; XDocument doc = XDocument.Load(file); try { root = doc.Element("plist").Element("dict"); XTPListXML.GetSubElement(root, "frames"); // 检测是否有贴图帧 XTPListXML.GetSubElement(root, "metadata/textureFileName"); // 检测贴图文件是否存在 } catch { throw new XTInvalidPListFileException(file); } return(new XTPListFile(file, root, isCache)); }