Actually, my first version creates a lot of sources and as a result I got a memory leak. So I decided to 'pre-create' all different sources and use them. But it looks like I can't reuse them.Ellohir wrote:Very cool; if only it sounded every time the circles touch and not one in four or five... Seems like the more circles I draw the more touches it doesn't sound
Circle music
Re: Circle music
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Circle music
A source is a single source of sound, so it can't be playing twice at the same time, probably causing these problems. What you could do is keep a list of sources, and when you need to play that sound, first check in the list if there is an unused one already:
Warning: untested, yadda yadda yadda
Code: Select all
function play_source(source_list, file_name)
for i, s in ipairs(source_list)
if s:isStopped() then
s:play()
return
end
end
local s = love.audio.newSource(file_name)
source_list[#source_list + 1] = s
s:play()
end
Help us help you: attach a .love.
- Taehl
- Dreaming in associative arrays
- Posts: 1025
- Joined: Mon Jan 11, 2010 5:07 am
- Location: CA, USA
- Contact:
Re: Circle music
Or let TEsound do that for you.
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Re: Circle music
Hey, thanks for helping me!
Here is the new version (now I store a list of sources for each unique sound).
Here is the new version (now I store a list of sources for each unique sound).
- Attachments
-
- circles_v1.1.love
- (2.34 MiB) Downloaded 146 times
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Circle music
Much better! Only sometimes there is no sound still. Also, circles inside other circles are invisible.
Help us help you: attach a .love.
Who is online
Users browsing this forum: Bing [Bot] and 3 guests