FlxSound always plays some samples before applying proximity factor



  • Hi,

    When I use proximity() method on FlxSound, it lowers volume with greater distance OK, but at any distance, it first plays small portion of it at full volume (and only then applies proximity).
    How can this be fought?

    Cheers



  • I do this. Not sure if it's the best way, but it works.

    FlxG.sound.load(soundFile, 0, true).play().fadeIn(1, 0, MaxVolume).proximity(midX, midY, ThePlayer, proximityRadius);



  • Thanks, but unfortunately, fadeIn doesn't fix things for me. I still get volume boost at start, shorter that a second, maybe for one frame.



  • This post is deleted!


  • @starry-abyss

    I just tried some tests and found that the play() part in my first post isn't even needed, although it still worked with it. Since it was working I didn't think much about it. This way is better.

    	FlxG.sound.load(soundFile, 0, true).proximity(midX, midY, player, proximityRadius).fadeIn(0.1, 0, 1);
    

    or

    	var snd = FlxG.sound.load(soundFile, 0, true);
    	snd.proximity(midX, midY, player, proximityRadius);
    	snd.fadeIn(0.1, 0, 1);
    
    

    I changed the fadeIn duration to 0.1 which is enough to prevent it from starting with that one frame 100% volume.

    This is working for me targeting flash, html5, neko, windows, android. I'm using mp3 for flash and ogg for the others.

    EDIT:
    You can use play(soundFile, 0, true) instead of load(soundFile, 0, true) if you want. Make sure the Volume argument is 0.



  • @dean Thanks for clarification, now it works! I forgot initial volume of 0.



  • @starry-abyss

    Happy to help when I can. Proximity is a cool feature!


Log in to reply