PauseView = Subview:extend { drawParent = true, --default? onNew = function (self) local boxW = 200 local boxH = 130 local boxL = the.app.width / 2 - boxW / 2 local boxT = the.app.height / 2 - boxH / 2 local boxR = boxL + boxW local boxB = boxT + boxH self.boxT = boxT local lh = 26 -- line height local buttonHeight = lh - 6 local buttonWidth = 150 self:add(Fill:new{ fill = {255,255,255}, x = boxL - 1, y = boxT - 1, width = boxW + 2, height = boxH + 2, }) self:add(Fill:new{ fill = {0,0,0}, x = boxL, y = boxT, width = boxW, height = boxH, }) self:add(Text:new{ text = 'Paused', x = boxL, y = boxT + 10, width = boxW, font = 16, align = 'center' }) local b = Button:new{ x = boxL + boxW / 2 - buttonWidth / 2, y = boxT + 40, label = Text:new{ text = 'Resume', --x = 3, y = 1, align = 'center', font = 16, width = buttonWidth }, background = Fill:new{ fill = {100,100,100}, width = buttonWidth, height = buttonHeight, }, onMouseUp = function() self:close() end } self:add(b) b = Button:new{ x = boxL + boxW / 2 - buttonWidth / 2, y = boxT + 40 + lh, label = Text:new{ text = 'Start new game', --x = 3, y = 1, align = 'center', font = 16, width = buttonWidth }, background = Fill:new{ fill = {100,100,100}, width = buttonWidth, height = buttonHeight, }, onMouseUp = function() self:close() the.app.view = GameView:new{newWorld = true} end } self:add(b) b = Button:new{ x = boxL + boxW / 2 - buttonWidth / 2, y = boxT + 40 + 2 * lh, label = Text:new{ text = 'Quit', --x = 3, y = 1, align = 'center', font = 16, width = buttonWidth }, background = Fill:new{ fill = {100,100,100}, width = buttonWidth, height = buttonHeight, }, onMouseUp = function() the.app:quit() end } self:add(b) -- give the buttons a cycle to get out of the T/L corner self:update(0) end, activate = function (self) the.cursor.visible = false love.mouse.setVisible(true) love.mouse.setGrab(false) love.mouse.setPosition(the.app.width / 2, self.boxT + 10 ) Subview.activate(self) end, close = function (self) the.cursor.visible = true love.mouse.setVisible(false) love.mouse.setGrab(true) love.mouse.setPosition(the.app.width / 2, the.app.height / 2) self:deactivate() end, onUpdate = function (self) if the.keys:justPressed('escape') then self:close() elseif the.keys:justPressed('q') then the.app:quit() end end }