/** * Checks to see if some <code>FlxObject</code> object overlaps this <code>FlxObject</code> object. * * @param Object The object being tested. * * @return Whether or not the two objects overlap. */ virtual public bool overlaps(FlxObject Object) { _point = getScreenXY(); float tx = _point.X; float ty = _point.Y; _point = Object.getScreenXY(); if ((_point.X <= tx - Object.width) || (_point.X >= tx + width) || (_point.Y <= ty - Object.height) || (_point.Y >= ty + height)) { return(false); } return(true); }
/** * Internal function that performs the actual logical updates to the sound object. * Doesn't do much except optional proximity and fade calculations. */ protected void updateSound() { if (_position != 0) { return; } float radial = 1.0f; float fade = 1.0f; if (_sound.State != SoundState.Playing) { active = false; } //Distance-based volume control if (_core != null) { Vector2 _point = new Vector2(); Vector2 _point2 = new Vector2(); _point = _core.getScreenXY(); _point2 = getScreenXY(); float dx = _point.X - _point2.X; float dy = _point.Y - _point2.Y; radial = (float)(_radius - Math.Sqrt(dx * dx + dy * dy)) / _radius; if (radial < 0) { radial = 0; } if (radial > 1) { radial = 1; } if (_pan) { float d = -dx / _radius; if (d < -1) { d = -1; } else if (d > 1) { d = 1; } if (_sound != null) { _sound.Pan = d; } } } //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; } _volumeAdjust = radial * fade; updateTransform(); }
/** * Checks to see if some <code>FlxObject</code> object overlaps this <code>FlxObject</code> object. * * @param Object The object being tested. * * @return Whether or not the two objects overlap. */ public virtual bool overlaps(FlxObject Object) { _point = getScreenXY(); float tx = _point.X; float ty = _point.Y; _point = Object.getScreenXY(); if((_point.X <= tx-Object.width) || (_point.X >= tx+width) || (_point.Y <= ty-Object.height) || (_point.Y >= ty+height)) return false; return true; }