private void pathLogic() { _currPos.make(x, y); if (moving) { makePathTimer += FlxG.elapsed; } if (makePathTimer >= 0.3) { if (FlxU.getDistance(_currPos, _lastPos) >= 5) { //FlxG.log(FlxU.getDistance(_currPos, _lastPos)); _lastPos.make(x, y); _nodes.Add(_lastPos); if (!_indoors) { footsteps.emitParticle(); } //FlxG.log("+node at ("+_currPos.x+", "+_currPos.y+")"); } makePathTimer = 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(); }