Created
April 14, 2017 21:01
-
-
Save tomires/24c396ce15b572b7c83fd52b37d10ea3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function init(self) | |
msg.post("#", "main_menu") | |
self.state = "MAIN_MENU" | |
msg.post(".", "acquire_input_focus") -- http://www.defold.com/manuals/input/#anchor-iacp | |
end | |
function on_message(self, message_id, m, sender) | |
if message_id == hash("main_menu") then | |
msg.post("#battle", "unload") | |
self.state = "MAIN_MENU" | |
msg.post("#menu", "load") | |
elseif message_id == hash("end_battle") then | |
print("WON: " .. tostring(m.won)) | |
print("CH1: " .. tostring(m.challenges[1][2])) | |
print("CH2: " .. tostring(m.challenges[2][2])) | |
msg.post("#battle", "unload") | |
self.state = "MAIN_MENU" | |
msg.post("#menu", "load") | |
elseif message_id == hash("battle_mode") then | |
msg.post("#menu", "unload") | |
msg.post("#menu", "disable") | |
msg.post("#battle", "load") | |
elseif message_id == hash("proxy_loaded") then | |
-- Board collection has loaded... | |
msg.post(sender, "init") | |
--msg.post("board:/board#script", "start_level", { difficulty = 1 }) | |
msg.post(sender, "enable") | |
self.state = "GAME_RUNNING" | |
print("Proxy loaded") | |
elseif message_id == hash("proxy_unloaded") then | |
print("Proxy unloaded") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment