예제 #1
0
        /// <summary>
        /// This function creates a flat colored square image dynamically.
        /// </summary>
        /// <param name="width">The width of the sprite you want to generate.</param>
        /// <param name="height">The height of the sprite you want to generate.</param>
        /// <param name="color">Specifies the color of the generated block.</param>
        /// <param name="unique">Whether the graphic should be a unique instance in the graphics cache. Default is false.</param>
        /// <param name="key">Optional parameter - specify a string key to identify this graphic in the cache. Trumps Unique flag.</param>
        /// <returns></returns>
        public FlxSprite makeGraphic(uint width, uint height, Color color, bool unique = false, string key = null)
        {
            /*
             * if (unique || !string.IsNullOrEmpty(key))
             * {
             * throw new NotSupportedException();
             * }
             */
            _bakedRotation = 0;
            _pixels        = FlxG.createBitmap(width, height, color, unique, key);

            Width       = width;
            FrameWidth  = width;
            Height      = height;
            FrameHeight = height;

            resetHelpers();

            // flx# stuff
            drawSourceRect = new Rectangle(0, 0, (int)width, (int)height);

            texture    = _pixels;
            sourceRect = new FlxRect(0, 0, width, height);

            return(this);
        }