How to turn off audio inside game loop

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
janglee
Prole
Posts: 19
Joined: Wed Jun 27, 2018 8:53 am

How to turn off audio inside game loop

Post by janglee »

hi everyone , i am working on 2d endless running game for android . I only want to mute all sounds with button just like other games . I can do it by putting every sound play statements inside if statement but it is not a proper way . can anyone suggest me how can i do that ?
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: How to turn off audio inside game loop

Post by Nixola »

You can use love.audio.setVolume to keep playing them while muted, or love.audio.stop to stop everything that's playing and then, as you said, not play anything unless it's unmuted. What you choose is up to you - I guess the former will be a bit heavier on the processor and/or battery and/or might mess with volume controls since it might technically still be playing sounds, and the music progresses while not heard so when someone unmutes it will be as if it never stopped; the latter will require "if guards" or similar, but it'll truly stop any audio from being played and processed; the music will resume from the beginning when unmuting.
This might all bee moot if LÖVE, or OpenAL, handles no volume as a special case; in that case, I guess it's just the same.
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
Post Reply

Who is online

Users browsing this forum: No registered users and 60 guests