I've been trying to make a nice sound for my game 'StarBase' for when the ship is flying around but I can't seem to get it right. The sounds are always played too far apart so that there is a gap or overlap so that it 'crackles'.
I've tried playing the sound every 4 frames (for example) and changing the speed of the sfx itself as well as how many notes are in the sfx but still no luck.
Any ideas on how to get a nice sounding sfx loop?
Ah no I didn't even see that... I'll try using it now!
I've tried using loops now and have something like this so far:
if dir_pressed() then sfx(0,1) else sfx(-2,1) end
The sound still seems to be starting every frame with this code though so I'll need to play around with the code a bit more.
That's because, if I understand your code correctly, you are checking every update frame and so playing every update frame.
What you need to do is tracking the change from no direction being pressed to any direction being pressed and back again.
key_down = False function _update() if not key_down and dir_pressed() then sfx(1,0) key_down = True elseif key_down and not dir_pressed() then sfx(-2,0) key_down = False end
[Please log in to post a comment]