You may have multiple ways to exit your game and so the love.quit() callback should handle those. I'm just giving an example. The exiting and focus_switch variables are both boolean values which you can switch to control how the callback works. If you only want one call, then you can reduce it to the followingKasperelo wrote:I don't really understand your example, sorry. What is the point of exiting and focus_switch exactly? On my friends Huawei, the problem seems to be that the game is still in focus after he has pressed the home button.GiveMeAnthony wrote:Alright, so maybe we ought to try something like this...Kasperelo wrote: That is part of my exit() function. It looked a little like this:Code: Select all
function exit() sfx.stop("music") -- Some code for stopping all sound effects love.event.quit() end
Code: Select all
local exiting = false -- we can set this to true from a user dialog local focus_switch = false -- we'll set this when the app goes out of focus function love.focus(in_focus) if not in_focus then focus_switch = true love.event.quit() end end function love.quit() if exiting then -- code to execute for exiting the program -- from a user dialog. Perhaps something to -- to ask if they'd really like to exit or not. return false elseif focus_switch then love.audio.stop() -- optionally, make multiple calls to love.audio.stop(source) -- where 'source' is a specific audio source. You can do this -- to only stop certain audio if you desire. -------------------------------------------------------------- -- If you must, call sfx.stop("music") and other code instead -- for stopping all other audio effects. return false end return true end
Code: Select all
function love.focus(in_focus)
if not in_focus then
love.event.quit()
end
end
function love.quit()
love.audio.stop()
-- optionally, make multiple calls to love.audio.stop(source)
-- where 'source' is a specific audio source. You can do this
-- to only stop certain audio if you desire.
--------------------------------------------------------------
-- If you must, call sfx.stop("music") and other code instead
-- for stopping all other audio effects.
return false
end
Code: Select all
function love.focus(in_focus)
if not in_focus then
love.audio.stop()
end
end