public Spriter(string scmlPath, FileLoader loader) { this.scmlPath = scmlPath; this.spriterData = Com.Brashmonkey.Spriter.xml.SCMLReader.load(scmlPath); this.loader = loader; loadResources(); }
// TODO MOAR HAX public static SpriterAnimationPlayer LoadAnimation(Game game, string file, ref SpriterRenderer <T> renderer) { SpriterData data = game.Content.Load <SpriterData>(file); object[] args = { game, data }; Type to = lookup[typeof(T)]; SpriterLoader <T> loader = Activator.CreateInstance(to, args) as SpriterLoader <T>; string root = file; if (root.Contains(Path.DirectorySeparatorChar)) { root = root.Substring(0, root.LastIndexOf(Path.DirectorySeparatorChar)); } else { root = ""; } loader.Load(root); SpriterAnimationPlayer player = new SpriterAnimationPlayer(data.GetEntity(0)); player.SetAnimation(0); renderer = Activator.CreateInstance(lookup2[typeof(T)], new object[] { loader }) as SpriterRenderer <T>; return(player); }
private static SpriterData load(System.IO.FileStream stream) { XmlReader reader = new XmlReader(); reader.parse(stream); XmlNode root = reader.getNode("spriter_data"); data = new SpriterData(); loadFolders(XmlReader.getChildrenByName(root, "folder")); loadEntities(XmlReader.getChildrenByName(root, "entity")); return(data); }
/// <summary>Constructs a new SpriterPlayer object which animates the given Spriter entity. /// </summary> /// <remarks>Constructs a new SpriterPlayer object which animates the given Spriter entity. /// </remarks> /// <param name="data"> /// /// <see cref="SpriterData">SpriterData /// </see> /// which provides a method to load all needed data to animate. See /// <see cref="Spriter#getSpriter(String,com.spriter.file.FileLoader)">Spriter#getSpriter(String,com.spriter.file.FileLoader) /// </see> /// for mor information. /// </param> /// <param name="entityIndex">The entity which should be handled by this player.</param> /// <param name="loader">The loader which has loaded all necessary sprites for the scml file. /// </param> public SpriterPlayer(SpriterData data, Entity entity, FileLoader loader) : base(loader, null) { this.entity = entity; this.frame = 0; if (!alreadyLoaded(entity)) { this.animations = SpriterKeyFrameProvider.generateKeyFramePool(data, entity); loaded.Add(entity, this); } else { this.animations = loaded[entity].animations; } this.generateData(); this.animation = this.animations[0]; this.firstKeyFrame = this.animation.frames[0]; this.update(0, 0); }
private void Init(string file) { data = owner.Game.Content.Load <SpriterData>(file); object[] args = { owner.Game, data }; Type to = lookup[typeof(T)]; loader = Activator.CreateInstance(to, args) as SpriterLoader <T>; string root = file; if (root.Contains(Path.DirectorySeparatorChar)) { root = root.Substring(0, root.LastIndexOf(Path.DirectorySeparatorChar)); } else { root = ""; } loader.Load(root); player = new SpriterAnimationPlayer(data.GetEntity(0)); player.SetAnimation(0); renderer = Activator.CreateInstance(lookup2[typeof(T)], new object[] { loader }) as SpriterRenderer <T>; }
/// <summary>Constructs a new SpriterPlayer object which animates the given Spriter entity. /// </summary> /// <remarks>Constructs a new SpriterPlayer object which animates the given Spriter entity. /// </remarks> /// <param name="data"> /// /// <see cref="SpriterData">SpriterData /// </see> /// which provides a method to load all needed data to animate. See /// <see cref="Spriter#getSpriter(String,com.spriter.file.FileLoader)">Spriter#getSpriter(String,com.spriter.file.FileLoader) /// </see> /// for mor information. /// </param> /// <param name="entityIndex">The index of the entity which should be handled by this player. /// </param> /// <param name="loader">The loader which has loaded all necessary sprites for the scml file. /// </param> public SpriterPlayer(SpriterData data, int entityIndex, FileLoader loader) : this(data, data.getEntity ()[entityIndex], loader) { }
public AtlasLoader(Game game, SpriterData data, string atlasFile) : base(game, data) { this.atlasFile = atlasFile; }
public Texture2DLoader(Game game, SpriterData data) : base(game, data) { }
protected SpriterLoader(Game game, SpriterData data) { Game = game; Data = data; Resources = new Dictionary <FileReference, R>(100); }