public void Load(CustomSpriteBatch spriteBatch, XmlTag xmlSheet, string strTextureFilename) { Debug.Assert(ans_pTexture == null); ans_pSpriteBatch = spriteBatch; ans_strTextureFilename = strTextureFilename; ans_pTexture = ContentRegister.Texture(strTextureFilename); if (xmlSheet.Attributes.ContainsKey("name")) { ans_strName = xmlSheet.Attributes["name"]; } XmlTag[] xmlAnimations; xmlAnimations = xmlSheet.FindTagsByName("anim"); for (int i = 0; i < xmlAnimations.Length; i++) { XmlTag tag = xmlAnimations[i]; Animation anim = new Animation(); anim.ani_pSheet = this; anim.Load(tag); ans_saAnimations.Add(anim); } }
public void Load(CustomSpriteBatch spriteBatch, string strFilename) { Unload(); XmlFile xmlFile = new XmlFile(strFilename.Replace(".png", ".xml")); XmlTag pSheets = xmlFile.Root.FindTagByName("sheets"); Debug.Assert(pSheets != null); if (pSheets == null) { return; } XmlTag[] sheets = pSheets.FindTagsByName("sheet"); for (int i = 0; i < sheets.Length; i++) { AnimationSheet sheet = new AnimationSheet(); sheet.Load(spriteBatch, sheets[i], strFilename); asc_saSheets.Add(sheet); } }
public void Load(XmlTag tagAnim) { if (tagAnim.Attributes.ContainsKey("name")) { ani_strName = tagAnim.Attributes["name"]; } if (tagAnim.Attributes.ContainsKey("size")) { ani_vSize = tagAnim.Attributes["size"].ParseVector2(); } if (tagAnim.Attributes.ContainsKey("offset")) { ani_rectOffset = tagAnim.Attributes["offset"].ParseRectangle(); } if (tagAnim.Attributes.ContainsKey("resetonactive")) { ani_bResetOnActive = bool.Parse(tagAnim.Attributes["resetonactive"]); } if (tagAnim.Attributes.ContainsKey("looping")) { ani_bLooping = bool.Parse(tagAnim.Attributes["looping"]); } if (tagAnim.Attributes.ContainsKey("startframe")) { ani_iStartFrame = Convert.ToInt32(tagAnim.Attributes["startframe"]); } if (tagAnim.Attributes.ContainsKey("loopframe")) { ani_iLoopFrame = Convert.ToInt32(tagAnim.Attributes["loopframe"]); } if (tagAnim.Attributes.ContainsKey("fliph")) { ani_bFlipH = bool.Parse(tagAnim.Attributes["fliph"]); } if (tagAnim.Attributes.ContainsKey("flipv")) { ani_bFlipV = bool.Parse(tagAnim.Attributes["flipv"]); } ani_state.iCurrentFrame = ani_iStartFrame; XmlTag[] xmlFrames; xmlFrames = tagAnim.FindTagsByName("frame"); for (int i = 0; i < xmlFrames.Length; i++) { XmlTag tag = xmlFrames[i]; AnimationFrame frame = new AnimationFrame(); frame.Load(tag); ani_saFrames.Add(frame); } XmlTag[] xmlAliases; xmlAliases = tagAnim.FindTagsByName("alias"); for (int i = 0; i < xmlAliases.Length; i++) { XmlTag tag = xmlAliases[i]; Animation anim = new Animation(); anim.ani_strName = tag.Attributes["name"]; anim.ani_pAliasOwner = this; if (tag.Attributes.ContainsKey("fliph")) { anim.ani_bFlipH = bool.Parse(tag.Attributes["fliph"]); } if (tag.Attributes.ContainsKey("flipy")) { anim.ani_bFlipH = bool.Parse(tag.Attributes["flipy"]); } if (tag.Attributes.ContainsKey("hue")) { anim.ani_iHue = Convert.ToInt32(tag.Attributes["hue"]); } ani_pSheet.ans_saAnimations.Add(anim); } }