I want to have, for now, 2 states: menu and world_map. Each one with its own lua file. In my main.lua i've got something like this:
Code: Select all
module(..., package.seeall)
require("entities")
require("menu")
require("world_map")
gamestate = require "hump.gamestate"
function love.load()
gamestate.registerEvents()
gamestate.switch(menu)
end
function love.update(dt)
entities:update(dt)
end
function love.keyreleased(key)
if key == "escape" then
love.event.quit()
end
end
function love.draw()
end
function love.quit()
print("Thanks for playing!")
end
Now, I want to switch state and would like to go the world_map when i press enter and for this purpose I write this:
Code: Select all
function menu:keyreleased(key)
if key == 'enter' then
print("I pressed enter")
gamestate.switch(world_map)
end
end
Can anyone give me an advice/example on how I should use properly HUMP.gamestate and what I'm missing in my current code (yes, they are just some snippets, but i thought it would be enough for my issue, i can give a .love if needed)?