예제 #1
0
파일: Plugin.cs 프로젝트: dstiert/Myra
        public override void OnLoad()
        {
            // Create resource asset resolver
            var assetResolver = new ResourceAssetResolver(GetType().Assembly, "Myra.Samples.Plugin.LibGDX.Resources.");

            // Load image containing font & ui spritesheet
            var colorBuffer = ColorBuffer.FromStream(assetResolver.Open("ui_stylesheet_image.png"));

            colorBuffer.PremultiplyAlpha();

            var texture = colorBuffer.CreateTexture2D();

            // Load ui text atlas
            var textureAtlas = TextureRegionAtlas.FromGDX(assetResolver.ReadAsString("ui_stylesheet_atlas.atlas"),
                                                          s => texture);

            // Load ui font(s)
            var font = SpriteFontHelper.LoadFromFnt(assetResolver.ReadAsString("ui_font.fnt"),
                                                    textureAtlas["default"]);

            // Load stylesheet
            var stylesheet = Stylesheet.CreateFromSource(assetResolver.ReadAsString("ui_stylesheet.json"),
                                                         s => textureAtlas[s],
                                                         s => font);

            Stylesheet.Current = stylesheet;
        }
예제 #2
0
        static void Main(string[] args)
        {
            if (args.Length < 2)
            {
                Console.WriteLine("ToMyraAtlasConverter converts LibGDX texture atlas to Myra texture atlas.");
                Console.WriteLine("Usage: ToMyraAtlasConverter <input.atlas> <output.json>");

                return;
            }

            try
            {
                var inputFile  = args[0];
                var outputFile = args[1];

                var inputData = File.ReadAllText(inputFile);
                var atlas     = TextureRegionAtlas.FromGDX(inputData, s => new Texture2D(null, 1, 1));

                var json = atlas.ToJson();
                File.WriteAllText(outputFile, json);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }