Beispiel #1
0
 public Spriter(string scmlPath, FileLoader loader)
 {
     this.scmlPath = scmlPath;
     this.spriterData = Com.Brashmonkey.Spriter.xml.SCMLReader.load(scmlPath);
     this.loader = loader;
     loadResources();
 }
Beispiel #2
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;
 }
        /// <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)
        {
        }
        /// <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);
        }