-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainScene.lua
59 lines (45 loc) · 1.18 KB
/
MainScene.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
-- Demo game for all these stuff
-- This is the title screen, which is the entry of game
function MainScene()
local Button = require "Button"
local self = SceneManager.newScene(love.graphics.getWidth(), love.graphics.getHeight())
local MapScene = require("MapScene")()
local btn0, btn1, btn2
local title_img = love.graphics.newImage("TankWarsTitle.png")
btn0 = Button.new(220, 290, 200, 40)
btn0.title = "New Game"
btn0.callback = function ()
SceneManager.load(MapScene)
end
btn1 = Button.new(220, 335, 200, 40)
btn1.title = "Load Game"
btn1.disabled = true
btn2 = Button.new(220, 380, 200, 40)
btn2.title = "Exit"
btn2.callback = function ()
love.event.quit()
end
self.mousepressed = function (x, y, button, isTouch)
btn0.onMousePress(x, y)
btn1.onMousePress(x, y)
btn2.onMousePress(x, y)
end
self.mousereleased = function (x, y, button, isTouch)
btn0.onMouseRelease(x, y)
btn1.onMouseRelease(x, y)
btn2.onMouseRelease(x, y)
end
self.update = function (dt)
btn0.update(dt)
btn1.update(dt)
btn2.update(dt)
end
self.draw = function ()
love.graphics.draw(title_img)
btn0.draw()
btn1.draw()
btn2.draw()
end
return self
end
return MainScene