Example #1
0
        Sprite[] LoadTemplate(string filename, string[] exts, Dictionary <string, ISpriteSource> sourceCache, int[] frames)
        {
            ISpriteSource source;

            if (!sourceCache.ContainsKey(filename))
            {
                using (var s = GlobalFileSystem.OpenWithExts(filename, exts))
                    source = SpriteSource.LoadSpriteSource(s, filename);

                if (source.CacheWhenLoadingTileset)
                {
                    sourceCache.Add(filename, source);
                }
            }
            else
            {
                source = sourceCache[filename];
            }

            if (frames != null)
            {
                var ret       = new List <Sprite>();
                var srcFrames = source.Frames.ToArray();
                foreach (var i in frames)
                {
                    ret.Add(sheetBuilder.Add(srcFrames[i]));
                }

                return(ret.ToArray());
            }

            return(source.Frames.Select(f => sheetBuilder.Add(f)).ToArray());
        }
Example #2
0
 Sprite[] CacheSpriteFrames(string filename)
 {
     using (var stream = GlobalFileSystem.OpenWithExts(filename, exts))
         return(SpriteSource.LoadSpriteSource(stream, filename).Frames
                .Select(a => SheetBuilder.Add(a))
                .ToArray());
 }