make() public method

Instantiate a new point object. The naming is very confusing... This method does not make or create a point (like the NEW keyword). Instead it only set's the X and Y value of the current instance and returnes this. So this is NOT a factory method.
public make ( float x, float y ) : FlxPoint
x float The X-coordinate of the point in space.
y float The Y-coordinate of the point in space.
return FlxPoint
Esempio n. 1
0
        /// <summary>
        /// Resets some important variables for sprite optimization and rendering.
        /// </summary>
        protected void resetHelpers()
        {
            _flashRect.X      = 0;
            _flashRect.Y      = 0;
            _flashRect.Width  = FrameWidth;
            _flashRect.Height = FrameHeight;

            _flashRect2.X      = 0;
            _flashRect2.Y      = 0;
            _flashRect2.Width  = _pixels.Width;
            _flashRect2.Height = _pixels.Height;

            /*
             * if ((framePixels == null) || (framePixels.width != width) || (framePixels.height != height))
             *  framePixels = new BitmapData(width, height);
             */

            Origin.make(FrameWidth * 0.5f, FrameHeight * 0.5f);

            //framePixels.copyPixels(_pixels, _flashRect, _flashPointZero);
            Frames = (uint)((_flashRect2.Width / _flashRect.Width) * (_flashRect2.Height / _flashRect.Height));
            //if (_colorTransform != null) framePixels.colorTransform(_flashRect, _colorTransform);

            _curIndex = 0;
        }
Esempio n. 2
0
 /// <summary>
 /// Move the camera focus to this location instantly.
 /// </summary>
 /// <param name="point">Where you want the camera to focus.</param>
 public void focusOn(FlxPoint point)
 {
     point.X += (point.X > 0) ? 0.0000001f : -0.0000001f;
     point.Y += (point.Y > 0) ? 0.0000001f : -0.0000001f;
     Scroll.make(point.X - Width * 0.5f, point.Y - Height * 0.5f);
 }
Esempio n. 3
0
        /// <summary>
        /// Updates the camera scroll as well as special effects like screen-shake or fades.
        /// </summary>
        public override void update()
        {
            //Either follow the object closely,
            //or doublecheck our deadzone and update accordingly.
            if (Target != null)
            {
                if (Deadzone == null)
                {
                    focusOn(Target.getMidpoint(_point));
                }
                else
                {
                    float edge;
                    //float targetX = FlxU.ceil(Target.X + ((Target.X > 0) ? 0.0000001f : -0.0000001f));
                    //float targetY = FlxU.ceil(Target.Y + ((Target.Y > 0) ? 0.0000001f : -0.0000001f));
                    float targetX = Target.X + ((Target.X > 0) ? 0.0000001f : -0.0000001f);
                    float targetY = Target.Y + ((Target.Y > 0) ? 0.0000001f : -0.0000001f);

                    edge = targetX - Deadzone.X;
                    if (Scroll.X > edge)
                    {
                        Scroll.X = edge;
                    }

                    edge = targetX + Target.Width - Deadzone.X - Deadzone.Width;
                    if (Scroll.X < edge)
                    {
                        Scroll.X = edge;
                    }

                    edge = targetY - Deadzone.Y;
                    if (Scroll.Y > edge)
                    {
                        Scroll.Y = edge;
                    }

                    edge = targetY + Target.Height - Deadzone.Y - Deadzone.Height;
                    if (Scroll.Y < edge)
                    {
                        Scroll.Y = edge;
                    }
                }
            }

            // Make sure we didn't go outside the camera's bounds
            if (Bounds != null)
            {
                //FlxG.log("bounds is not null");
                if (Scroll.X < Bounds.Left)
                {
                    Scroll.X = Bounds.Left;
                }

                if (Scroll.X > Bounds.Right - Width)
                {
                    Scroll.X = Bounds.Right - Width;
                }

                if (Scroll.Y < Bounds.Top)
                {
                    Scroll.Y = Bounds.Top;
                }

                if (Scroll.Y > Bounds.Bottom - Height)
                {
                    Scroll.Y = Bounds.Bottom - Height;
                }
            }

            // Update the "flash" special effect
            if (fxFlashAlpha > 0.0)
            {
                fxFlashAlpha -= FlxG.elapsed / fxFlashDuration;
                if (fxFlashAlpha <= 0)
                {
                    fxFlashAlpha = 0;
                    if (fxFlashComplete != null)
                    {
                        fxFlashComplete();
                    }
                }
            }

            // Update the "fade" special effect
            if ((fxFadeAlpha > 0.0) && (fxFadeAlpha < 1.0))
            {
                fxFadeAlpha += FlxG.elapsed / fxFadeDuration;
                if (fxFadeAlpha >= 1.0)
                {
                    //fxFadeAlpha = 1.0f;
                    fxFadeAlpha = 0;
                    if (fxFadeComplete != null)
                    {
                        fxFadeComplete();
                    }
                }
            }

            // Update the "shake" special effect
            if (fxShakeDuration > 0)
            {
                fxShakeDuration -= FlxG.elapsed;
                if (fxShakeDuration <= 0)
                {
                    fxShakeOffset.make();
                    if (fxShakeComplete != null)
                    {
                        fxShakeComplete();
                    }
                }
                else
                {
                    if ((fxShakeDirection == ShakeBothAxes) || (fxShakeDirection == ShakeHorizontalOnly))
                    {
                        fxShakeOffset.X = (FlxG.random() * fxShakeIntensity * Width * 2 - fxShakeIntensity * Width) * _zoom;
                    }

                    if ((fxShakeDirection == ShakeBothAxes) || (fxShakeDirection == ShakeVerticalOnly))
                    {
                        fxShakeOffset.Y = (FlxG.random() * fxShakeIntensity * Height * 2 - fxShakeIntensity * Height) * _zoom;
                    }
                }
            }

            // flx#
            //Scroll.X -= fxShakeOffset.X;
            //Scroll.Y -= fxShakeOffset.Y;

            //if (zooming < 1)
            //    zooming = 1;
        }