How do sound effects work?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- Joelrodiel
- Prole
- Posts: 27
- Joined: Wed Apr 20, 2016 3:40 am
How do sound effects work?
I have tried lots of things, but still don't know how to play sound effects. By sound effects I mean playing a certain sound for a certain time and then making it stop COMPLETELY. I have looked everywhere but can't seem to find the answer, maybe because its a really noobish question, I don't know. Every time I play sounds they just end up looping. Thanks in advance.
Re: How do sound effects work?
Sounds do not loop unless you tell them to.
If your sound loops anyway, you may have found a bug. Can you attach a short .love file that exhibits the problem?
Code: Select all
local snd = love.audio.newSource('mysound.ogg')
-- snd:setLooping(true) -- if you enable this, it will loop; otherwise it won't
snd:play()
- zorg
- Party member
- Posts: 3470
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: How do sound effects work?
Also, make sure you're not calling, for example, snd:play(), going by pgimeno's example, in love.update just like that, since that's not how it works.
Last edited by zorg on Wed Apr 20, 2016 1:51 pm, edited 1 time in total.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
- Joelrodiel
- Prole
- Posts: 27
- Joined: Wed Apr 20, 2016 3:40 am
Re: How do sound effects work?
Here is one of my attempts of making a sound effect. Just some dumb thing I made to test sound effects and pictures. Also, thanks for the fast replies
- Attachments
-
- geltaingame.love
- (299.19 KiB) Downloaded 184 times
Re: How do sound effects work?
The problem is what zorg said. You keep triggering bop:play(). Try adding pressed = false after bop:play().
You may also want to have another variable to track whether the button was pressed in the previous frame, so that it only plays when it was off in the previous frame and on in the current frame. That will prevent it to keep playing while pressed.
You may also want to have another variable to track whether the button was pressed in the previous frame, so that it only plays when it was off in the previous frame and on in the current frame. That will prevent it to keep playing while pressed.
- zorg
- Party member
- Posts: 3470
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: How do sound effects work?
I'd urge you not to open this link (just yet), but it has a solution: http://pastebin.com/q201JjHf
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
- Joelrodiel
- Prole
- Posts: 27
- Joined: Wed Apr 20, 2016 3:40 am
Re: How do sound effects work?
So should I open it? :0zorg wrote:I'd urge you not to open this link (just yet), but it has a solution: http://pastebin.com/q201JjHf
- Joelrodiel
- Prole
- Posts: 27
- Joined: Wed Apr 20, 2016 3:40 am
Re: How do sound effects work?
So I fixed it. Now I made it so when you click it will make the sound effect and change the picture. Thank you so much for your quick responses. Have a nice day.
- Attachments
-
- gelatinRINKAH.love
- (299.2 KiB) Downloaded 192 times
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest