Page 1 of 1

State-Based Menu

Posted: Sun Jan 19, 2014 7:19 am
by metzyn
This is my first library, a very simple state-based menu. I'm looking for constructive feedback and to see if it might be useful beyond myself.

You can customize the font, color scheme, spacing and sizing by editing the library directly, all easily found in the top of the file.



Example code:

Code: Select all

GAME_STATE = "MY_MENU"

myMain = StateBasedMenu.create("My Menu",
	{"Menu Item 1", "Menu Item 2", "Menu Item 3"},
	{"MENU_ITEM_1", "MENU_ITEM_2", "MENU_ITEM_3"})

function love.update(delta)
	if GAME_STATE == "MY_MENU" then
		myMenu:update()
		if myMenu:getState() ~= nil then GAME_STATE = myMenu:getState() end
	end
end

function love.draw()
	if GAME_STATE == "MY_MENU" then
		myMenu:draw()
	end
end