getMidpoint() public method

Retrieve midpoint of this object in world coordinates
public getMidpoint ( FlxPoint Point = null ) : FlxPoint
Point FlxPoint
return FlxPoint
Example #1
0
        /**
         * Handles fade out, fade in, panning, proximity, and amplitude operations each frame.
         */
        override public void update()
        {
            base.update();
            if (_source != null)
            {
                x = _source.getMidpoint().x;
                y = _source.getMidpoint().y;
            }

            float radial = 1.0f;
            float fade   = 1.0f;

            //Distance-based volume control
            if (_target != null)
            {
                radial = (_radius - FlxU.getDistance(_target.getMidpoint(), new FlxPoint(x, y))) / _radius;
                if (radial < 0)
                {
                    radial = 0;
                }
                if (radial > 1)
                {
                    radial = 1;
                }
            }

            //Cross-fading volume control
            if (_fadeOutTimer > 0)
            {
                _fadeOutTimer -= FlxG.elapsed;
                if (_fadeOutTimer <= 0)
                {
                    if (_pauseOnFadeOut)
                    {
                        pause();
                    }
                    else
                    {
                        stop();
                    }
                }
                fade = _fadeOutTimer / _fadeOutTotal;
                if (fade < 0)
                {
                    fade = 0;
                }
            }
            else if (_fadeInTimer > 0)
            {
                _fadeInTimer -= FlxG.elapsed;
                fade          = _fadeInTimer / _fadeInTotal;
                if (fade < 0)
                {
                    fade = 0;
                }
                fade = 1 - fade;
            }

            if ((autoDestroy && playCount > 0) && (_sound.State != SoundState.Paused && _sound.State != SoundState.Playing))
            {
                _sound.Dispose();
            }

            _volumeAdjust = radial * fade;
            updateTransform();
        }
Example #2
0
 /**
  * Change the emitter's midpoint to match the midpoint of a <code>FlxObject</code>.
  *
  * @param	Object		The <code>FlxObject</code> that you want to sync up with.
  */
 public void at(FlxObject Object)
 {
     Object.getMidpoint(_point);
     x = _point.x - (Convert.ToInt32(width) >> 1);
     y = _point.y - (Convert.ToInt32(height) >> 1);
 }
Example #3
0
 /**
  * Change the emitter's midpoint to match the midpoint of a <code>FlxObject</code>.
  *
  * @param	Object		The <code>FlxObject</code> that you want to sync up with.
  */
 public void at(FlxObject Object)
 {
     Object.getMidpoint(_point);
     x = _point.x - (Convert.ToInt32(width)>>1);
     y = _point.y - (Convert.ToInt32(height)>>1);
 }