예제 #1
0
        public Array findRegions(string str)
        {
            Array result = new Array();

            for (int i = 0; i < _atlasImages.size; i++)
            {
                TextureAtlasRegion textureAtlasRegion = _atlasImages.get(i) as TextureAtlasRegion;
                if (textureAtlasRegion.getName().Equals(str))
                {
                    result.add(textureAtlasRegion);
                }
            }
            return(result);
        }
예제 #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++;
            }
        }