Пример #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 = (RenderTarget2D)screen.Pixels;
            BgColor = FlxG.bgColor;

            _color = Color.White;
            /*
            _flashBitmap = new Bitmap(buffer);
            _flashBitmap.x = -width*0.5;
            _flashBitmap.y = -height*0.5;
            _flashSprite = new Sprite();
            */
            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();
        }
Пример #2
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 = (RenderTarget2D)screen.Pixels;
            BgColor = FlxG.bgColor;

            _color = Color.White;

            /*
             * _flashBitmap = new Bitmap(buffer);
             * _flashBitmap.x = -width*0.5;
             * _flashBitmap.y = -height*0.5;
             * _flashSprite = new Sprite();
             */
            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();
        }