[SOLVED cause im stupid] I don't even know what to title this, sorry.
Posted: Thu Feb 21, 2019 9:28 pm
I have an extremely strange issue which I haven't been able to solve for about two weeks now.
I have 6 .lua files, each a different screen for parts of my game.
When I get moved to deathScreen.lua (which is normal) and press any key, my music goes silent (not normal). I do have other files and I'll give the code to each love.keypressed(key) function which exists.
game.lua:
home.lua:
The the music which stops playing is bgm not music.
I also had an issue where my mouse would also become invisible whenever I press a key, but I solved that by just seeing if it was invisible, if so, make it visible. Not clean code I know, but it gets the job done.
I feel like if I just make the love.keypressed(key) function private/local (I don't know how to) it might fix my issue.
I'm sorry for being so vague, I just don't know what to actually put as I don't understand this problem in the slightest bit.
I would give the files but I don't think there's any need and I don't expect anyone to waste their time going through hundreds of lines of code just for me.
Thanks!
P.S. English isn't my first language so sorry if this makes no sense.
I have 6 .lua files, each a different screen for parts of my game.
When I get moved to deathScreen.lua (which is normal) and press any key, my music goes silent (not normal). I do have other files and I'll give the code to each love.keypressed(key) function which exists.
game.lua:
Code: Select all
function love.keypressed(key)
if key == 'space' then
if (not lost) and escKey == 0 then
if not grow then
grow = true
else
grow = false
end
end
end
if key == 'escape' and escKey == 0 then
escKey = 1
music:pause()
bgm:play()
love.mouse.setVisible(true)
--PAUSE THE GAME
else
escKey = 0
music:resume()
love.audio.stop(bgm)
love.mouse.setVisible(false)
--CONTINUE THE GAME
end
if key == 'h' then
if love.mouse.isVisible() == true then
love.mouse.setVisible(false)
else
love.mouse.setVisible(true)
end
end
if key == 'm' then
if music:getVolume() > 0 then
music:setVolume(0)
else
music:setVolume(v)
end
end
end
Code: Select all
function love.keypressed(key)
if key == 'm' then
if bgm:getVolume() > 0 then
bgm:setVolume(0)
else
bgm:setVolume(0.3)
end
end
end
I also had an issue where my mouse would also become invisible whenever I press a key, but I solved that by just seeing if it was invisible, if so, make it visible. Not clean code I know, but it gets the job done.
I feel like if I just make the love.keypressed(key) function private/local (I don't know how to) it might fix my issue.
I'm sorry for being so vague, I just don't know what to actually put as I don't understand this problem in the slightest bit.
I would give the files but I don't think there's any need and I don't expect anyone to waste their time going through hundreds of lines of code just for me.
Thanks!
P.S. English isn't my first language so sorry if this makes no sense.