-
Notifications
You must be signed in to change notification settings - Fork 0
/
menu_state.lua
50 lines (39 loc) · 1.09 KB
/
menu_state.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
local Object = require("lib.classic")
local BaseState = require("base_state")
local MenuState = BaseState:extend()
function MenuState:new(startMenu)
BaseState.new(self)
self.startMenu = startMenu
self.super.registerPressEventHandler(self,"ui_cancel", self.back)
self.super.registerPressEventHandler(self, "down", self.next)
self.super.registerPressEventHandler(self, "up", self.previous)
self.super.registerPressEventHandler(self,"ui_accept", self.accept)
end
function MenuState:enter()
menuStack:clear()
menuStack:push(self.startMenu)
end
function MenuState:next()
menuStack:next()
end
function MenuState:previous()
menuStack:previous()
end
function MenuState:accept()
menuStack:accept()
end
function MenuState:back()
if (#menuStack.stack > 1) then
menuStack:pop()
end
end
function MenuState:update(dt)
menuStack:update(dt)
end
function MenuState:draw()
love.graphics.setColor(0, 0, 0, 0.8)
love.graphics.rectangle("fill", 0, 0, DRAW_WIDTH, DRAW_HEIGHT)
love.graphics.setColor(1, 1, 1, 1)
menuStack:draw()
end
return MenuState