I have a few game "states" that I'm using ("INTRO", "MENU", "GAME"). I am aware of state machines and such, but for this project I am not using any external libs other then to recursively print tables for troubleshooting.
For each, i have something.lua, each having an update and draw function. For example.
Code: Select all
function Menu:update(speedAdjustment)
...
end
Code: Select all
function love.update(dt)
if Settings.GlobalStates.activeScene == 'GAME' then
Input:update(dt * Settings.gameSpeed)
Ball:update(dt * Settings.gameSpeed)
elseif Settings.GlobalStates.activeScene == 'INTRO' then
Intro:update(dt)
elseif Settings.GlobalStates.activeScene == 'MENU' then
Menu:update(dt)
end
end
However, when I transition I am running into trouble. Here's what happens,
Intro:update runs as expected until there is nothing left to do. It then transitions:
Code: Select all
-- in Intro:update
Settings.GlobalStates.activeScene = 'MENU'
I tried to make a "toggle switch" to bypass that first run.
Code: Select all
function Menu:draw()
-- (updateHasRun) and true or return
if (updateHasRun ~= true) then
print('nah dont do it')
return
end
menuState.drawAction()
end