Skip to content

ommann/finger-love2d

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Finger

Module for creating table-based menu for love2d.

Full Example

cursor = require 'finger'

love.load = function(dt)
  --String in the first index is used as the default entry point
  menu = {"Item"}

  --Strings in navigation refers to other menu elements, functions to logic to be executed
  menu.Item = {up = "Magic", down = "Magic", x = 100, y = 100}

  --Navigation is resolved locally then globally
  menu.Item.escape = function() print("specific escape action") end
  menu.escape = function() cursor:enter(menu); print("default escape action") end

  --Menu entries can have their own data fields as well
  menu.Magic = {up = "Item", down = "Item", x = 100, y = 120}
  menu.Magic.enter = function() print("specific enter action") end

  cursor:enter(menu)
end

love.draw = function()
  love.graphics.print(cursor.item.x.." "..cursor.item.y)
  love.graphics.circle("fill", cursor.item.x, cursor.item.y, 5, 10)
end

love.keypressed = function(key)
  --return is a reserved word
  if key == "return" then key = "enter" end

  --Object is used as a function to navigate in the menu
  cursor(key)
end

About

Module for creating table-based menu for love2d.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages