Code: Select all
--- main.lua
function love.load()
StateMachine:addState(1, introState)
StateMachine:addState(2, mainState)
StateMachine:setState(1)
end
function love.draw(screen) ---lovepotion-specific parameter
StateMachine:draw(screen)
end
Code: Select all
--- StateMachine.lua
function StateMachineClass:draw(screen)
if (_currentState == nil) then return end
_states[_currentState]:draw(screen)
end
Code: Select all
--- State.lua
function State:initialize(draw)
self.draw = draw;
end
Code: Select all
--- introState.lua -
local function draw(screen)
love.graphics.print("intro")
print("intro")
end
return State:new(
draw
)
Any clue why this might be happening? If I put the same statements into main.lua love.draw() function, or even like my library dslayout - outside of main.lua, it works without a hitch.