Ejemplo n.º 1
0
        public Array findRegions(string str)
        {
            var images = new MonoGameTextureAtlasImage[_atlasImages[str].Count];

            _atlasImages[str].Values.CopyTo(images, 0);
            System.Array.Sort(images);
            var regions = new MonoGameTextureAtlasRegion[images.Length];

            for (var i = 0; i < images.Length; i++)
            {
                regions[i] = images[i].textureRegion;
            }
            return(Array.with(regions));
        }
Ejemplo n.º 2
0
        public MonoGameTextureAtlas(FileHandle atlasFile, FileHandle imagesDir, bool flip)
        {
            var             lines = ((MonoGameFileHandle)atlasFile).readAllLines();
            var             i     = 1;
            MonoGameTexture packTexture;

            while (i < lines.Length)
            {
                packTexture = (MonoGameTexture)Mdx.graphics.newTexture(imagesDir.child(lines[i]));
                i          += 5; //skip size, format, filter and repeat;
                while (i < lines.Length && lines[i] != string.Empty)
                {
                    int    index, x, y, width, height, originalWidth, originalHeight, offsetX, offsetY;
                    string name   = lines[i];
                    bool   rotate = bool.Parse(lines[i + 1].Split(':')[1]);

                    readTuple(lines[i + 2], out x, out y);
                    readTuple(lines[i + 3], out width, out height);
                    readTuple(lines[i + 4], out originalWidth, out originalHeight);
                    readTuple(lines[i + 5], out offsetX, out offsetY);
                    index = int.Parse(lines[i + 6].Split(':')[1]);

                    var image = new MonoGameTextureAtlasRegion(packTexture, name, index, x, y, width, height, rotate);
                    image.originalWidth  = originalWidth;
                    image.originalHeight = originalHeight;
                    image.offsetX        = offsetX;
                    image.offsetY        = offsetY;

                    _atlasImages.add(image);

                    i += 7;
                }

                i++;
            }
        }