Author Topic: v1.25 - Very strange sound pausing bug + very minor speed up  (Read 1321 times)

Cthulhu32

  • Guest
Hey Adam,

   I was chatting with you a bit yesterday at the Jam about this, but I was having the most bizarre issue where sometimes when the character landed or jumped or something, the game would stutter and ONLY on my computer. So I was flying back home, and I finally thought to try removing the sounds for landing and getting stars, and I realized it was in the new sound transform that I was getting the bug. So I took a look at FlxG.as and found the play() call, and noticed something.

line 132: (new SoundEffect).play(0,0,new SoundTransform(Volume*_muted*_volume*_masterVolume));

_muted is an integer value, so you're essentially still creating a sound transform when the game is muted but its being played back at 0. If you wanted to, you could simplify this down and make it so if you did have a stutter issue, you could simply mute the game. Here's the code I replaced this with.

if (_muted) (new SoundEffect).play(0,0,new SoundTransform(Volume*_volume*_masterVolume));

This also saves you one value in the multiplication at the cost of one if check (and if check should be faster than a multiplication in flash, not sure though.) Also, if the user mutes the game, there are no more sound transforms being created wasting resources. Hopefully this helps anyone who experiences this bizarre sound stuttering bug. I've had 2 computers do it so far out of probably 8 or 9 tested.

- Thanks!
    Luke