State-Based Menu

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
metzyn
Prole
Posts: 6
Joined: Wed Mar 27, 2013 10:51 pm
Location: TN, USA

State-Based Menu

Post 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
Attachments
state_based_menu.lua
(4.07 KiB) Downloaded 175 times
Post Reply

Who is online

Users browsing this forum: No registered users and 66 guests