-
Notifications
You must be signed in to change notification settings - Fork 0
/
SceneManager.lua
68 lines (51 loc) · 1.27 KB
/
SceneManager.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
62
63
64
65
66
67
68
local SceneManager = {}
local sc
SceneManager.load = function (new)
SceneManager.current = new
sc = SceneManager.current
end
-- Prototype of Scene
SceneManager.newScene = function (w, h)
self = {}
self.canvas = love.graphics.newCanvas(w, h)
self.mousepressed = function (x, y, button, isTouch)
end
self.mousereleased = function (x, y, button, isTouch)
end
self.keypressed = function (key, scancode, isrepeat)
end
self.keyreleased = function (key)
end
self.update = function (dt)
end
self.draw = function ()
end
return self
end
SceneManager.mousepressed = function (x, y, button, isTouch)
sc.mousepressed(x, y, button, isTouch)
end
SceneManager.mousereleased = function (x, y, button, isTouch)
sc.mousereleased(x, y, button, isTouch)
end
SceneManager.keypressed = function (key, scancode, isrepeat)
sc.keypressed(key, scancode, isrepeat)
end
SceneManager.keyreleased = function (key)
sc.keyreleased(key)
end
SceneManager.update = function (dt)
sc.update(dt)
end
-- Render scene to canvas
SceneManager.draw = function ()
love.graphics.push()
-- love.graphics.setCanvas(sc.canvas)
-- love.graphics.clear()
-- love.graphics.setBlendMode("alpha")
sc.draw()
-- love.graphics.setCanvas()
love.graphics.pop()
-- love.graphics.draw(sc.canvas)
end
return SceneManager