-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscene.lua
More file actions
36 lines (30 loc) · 789 Bytes
/
Copy pathscene.lua
File metadata and controls
36 lines (30 loc) · 789 Bytes
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
local M = {
gameplay = require("scenes.gameplay"),
main_menu = require("scenes.main_menu"),
pattern_test = require("scenes.pattern_test"),
movement_test = require("scenes.movement_test"),
}
M.KEY = {
GAMEPLAY = "gameplay",
MAIN_MENU = "main_menu",
PATTERN_TEST = "pattern_test",
MOVEMENT_TEST = "movement_test",
}
-- State stores the scene key (a string), not the module table so that module
-- references don't go stale
function M.switch_to(key)
assert(M[key], "unknown scene: " .. tostring(key))
print("switch_to: " .. key)
if State.current_scene == nil then
State.current_scene = key
if M[key].init then
M[key].init(State)
end
else
State.pending_scene = key
end
end
function M.current()
return M[State.current_scene]
end
return M