Esempio n. 1
0
 public Spriter(string scmlPath, FileLoader loader)
 {
     this.scmlPath    = scmlPath;
     this.spriterData = Com.Brashmonkey.Spriter.xml.SCMLReader.load(scmlPath);
     this.loader      = loader;
     loadResources();
 }
Esempio n. 2
0
        // 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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
 /// <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);
 }
Esempio n. 5
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>;
        }
Esempio n. 6
0
 /// <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)
 {
 }
Esempio n. 7
0
 public AtlasLoader(Game game, SpriterData data, string atlasFile) : base(game, data)
 {
     this.atlasFile = atlasFile;
 }
Esempio n. 8
0
 public Texture2DLoader(Game game, SpriterData data) : base(game, data)
 {
 }
Esempio n. 9
0
 protected SpriterLoader(Game game, SpriterData data)
 {
     Game      = game;
     Data      = data;
     Resources = new Dictionary <FileReference, R>(100);
 }