Пример #1
0
        /// <summary>
        /// Constructs a sprite from a resource.
        /// </summary>
        /// <param name="resources"></param>
        /// <param name="name"></param>
        public Sprite(AgateResourceCollection resources, string name)
        {
            AgateResource  generic_res = resources[name];
            SpriteResource sprite_res  = generic_res as SpriteResource;

            if (sprite_res == null)
            {
                throw new AgateResourceException("Resource " + generic_res.Name + " is not a sprite.");
            }

            BuildSpriteFromResource(resources, resources.RootDirectory, sprite_res);
        }
Пример #2
0
        /// <summary>
        /// Constructs a FontSurface object from a resource.
        /// </summary>
        /// <param name="resources"></param>
        /// <param name="resourceName"></param>
        public FontSurface(AgateResourceCollection resources, string resourceName)
        {
            AgateResource      res     = resources[resourceName];
            BitmapFontResource bmpFont = res as BitmapFontResource;

            if (res is BitmapFontResource)
            {
                Surface surf = new Surface(bmpFont.Image);

                impl = new BitmapFontImpl(surf, bmpFont.FontMetrics);
            }
            else
            {
                throw new AgateResourceException(string.Format(
                                                     "The resource {0} is of type {1} which cannot be used to construct a font.",
                                                     resourceName, res.GetType().Name));
            }
        }