private PlayerSpriteSheet loadAnimation(XmlNode animationNode) { PlayerSpriteSheet playerSpriteSheet = null; try { PlayerSpriteSheet.Type type = PlayerSpriteSheet.getTypeFromString(animationNode.Attributes["type"].Value); PlayerSpriteSheet.Mode mode = PlayerSpriteSheet.getModeFromString(animationNode.Attributes["mode"].Value); string textureName = animationNode.Attributes["texture"].Value; // Check to see if the texture has already been loaded into our asset manager playerSpriteSheet = (PlayerSpriteSheet)lhg.Assets.findSpriteSheet(textureName); if (playerSpriteSheet == null) { Texture2D texture = lhg.Content.Load <Texture2D>(textureName); List <Animation> positions = loadPositions(animationNode); playerSpriteSheet = new PlayerSpriteSheet(lhg, type, mode, textureName, texture, positions); lhg.Assets.addSpriteSheet(playerSpriteSheet); progress.updateProgress("Loading player sprite sheet " + textureName, "Loading", 0); } else { progress.updateProgress("Using sprite sheet from cache " + textureName, "Loading", 0); } //int framesPerSecond = Convert.ToInt16(animationNode.Attributes["framesPerSecond"].Value); } catch (Exception ex) { } return(playerSpriteSheet); }
private List <PlayerSpriteSheet> loadAnimations(XmlNode animationsNode) { List <PlayerSpriteSheet> playerSpriteSheetList = new List <PlayerSpriteSheet>(); XmlNodeList childNodes = animationsNode.ChildNodes; foreach (XmlNode animationNode in childNodes) { if (animationNode.Name.Equals("animation")) { PlayerSpriteSheet playerSpriteSheet = loadAnimation(animationNode); if (playerSpriteSheet != null) { playerSpriteSheetList.Add(playerSpriteSheet); } } } return(playerSpriteSheetList); }