-
Notifications
You must be signed in to change notification settings - Fork 0
/
menu.lua
61 lines (40 loc) · 768 Bytes
/
menu.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
Menu = class("Menu")
---
-- Menu:initialize
-- The base class for every Menu. Override this in a menu.
--
function Menu:initialize()
self.items = {}
self.nexty = 60
end
---
-- Menu:addItem
-- Adds an item to the menu.
--
-- @param item An item object to add, eg. a Button.
--
function Menu:addItem(item)
item.y = self.nexty
table.insert(self.items, item)
self.nexty = self.nexty + item.height
end
---
-- Menu:update
-- Handles input and stuff.
--
-- @param dt Time passed since last frame
--
function Menu:update(dt)
for k,v in pairs(self.items) do
v:update(dt)
end
end
---
-- Menu:draw
-- Draws the menu.
--
function Menu:draw()
for k,v in pairs(self.items) do
v:draw()
end
end