flxSharp.flxSharp.FlxSprite.makeGraphic C# (CSharp) Méthode

makeGraphic() public méthode

This function creates a flat colored square image dynamically.
public makeGraphic ( uint width, uint height, Color color, bool unique = false, string key = null ) : FlxSprite
width uint The width of the sprite you want to generate.
height uint The height of the sprite you want to generate.
color Color Specifies the color of the generated block.
unique bool Whether the graphic should be a unique instance in the graphics cache. Default is false.
key string Optional parameter - specify a string key to identify this graphic in the cache. Trumps Unique flag.
Résultat FlxSprite
        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;
        }

Usage Example

Exemple #1
0
        /// <summary>
        /// Instantiates a new camera at the specified location, with the specified size and zoom level.
        /// </summary>
        /// <param name="x">X location of the camera's display in pixels. Uses native, 1:1 resolution, ignores zoom.</param>
        /// <param name="y">Y location of the camera's display in pixels. Uses native, 1:1 resolution, ignores zoom.</param>
        /// <param name="width">The width of the camera display in pixels.</param>
        /// <param name="height">The height of the camera display in pixels.</param>
        /// <param name="zoom">The initial zoom level of the camera. A zoom level of 2 will make all pixels display at 2x resolution.</param>
        public FlxCamera(float x, float y, int width, int height, float zoom = 0)
            : base()
        {
            X        = x;
            Y        = y;
            Width    = width;
            Height   = height;
            Target   = null;
            Deadzone = null;
            Scroll   = new FlxPoint();
            _point   = new FlxPoint();
            Bounds   = null;
            screen   = new FlxSprite();
            screen.makeGraphic((uint)width, (uint)height, new Color(0, 0, 0, 0));
            screen.setOriginToCorner();
            //Buffer = screen.Pixels;
            BgColor = FlxG.bgColor;

            _color = Color.White;
            //_color = 0xffffffff;

            /*
             *          _flashBitmap = new Bitmap(buffer);
             *          _flashBitmap.x = -width*0.5;
             *          _flashBitmap.y = -height*0.5;
             *          _flashSprite = new Sprite();
             */

            // flx# - ?
            // zoom = Zoom; //sets the scale of flash sprite, which in turn loads flashoffset values

            /*
             * _flashOffsetX = width*0.5*zoom;
             *          _flashOffsetY = height*0.5*zoom;
             *          _flashSprite.x = x + _flashOffsetX;
             *          _flashSprite.y = y + _flashOffsetY;
             *          _flashSprite.addChild(_flashBitmap);
             *          _flashRect = new Rectangle(0,0,width,height);
             *          _flashPoint = new Point();
             */

            fxFlashColor    = Color.Black;
            fxFlashDuration = 0.0f;
            fxFlashComplete = null;
            fxFlashAlpha    = 0.0f;

            fxFadeColor    = Color.Black;
            fxFadeDuration = 0.0f;
            fxFadeComplete = null;
            fxFadeAlpha    = 0.0f;

            fxShakeIntensity = 0.0f;
            fxShakeDuration  = 0.0f;
            fxShakeComplete  = null;
            fxShakeOffset    = new FlxPoint();
            fxShakeDirection = 0;

            //_fill = new BitmapData(width,height,true,0);

            // flx#
            //DefaultZoom = 1.0f;
            rotating    = 0.0f;
            Zoom        = zoom;
            FlashSprite = new FlxObject();
            //BgColor = Color.Black;

            _fxHelperTexture = new Texture2D(FlxS.GraphicsDevice, 1, 1, false, SurfaceFormat.Color);
            _fxHelperTexture.SetData(new[] { Color.White });

            _fillTexture = new Texture2D(FlxS.GraphicsDevice, 1, 1, false, SurfaceFormat.Color);
            _fillTexture.SetData(new[] { Color.White });

            UpdateHelpers();
        }
All Usage Examples Of flxSharp.flxSharp.FlxSprite::makeGraphic