So here’s my code for my gui_script but when i try it it doesn’t work !
function init(self)
self.score = 0
self.GameOver = false
self.pause = false
self.score_node = gui.get_node("coin")
self.game_over = gui.get_node("game_over")
self.retry = gui.get_node("retry")
msg.post("#", "acquire_input_focus")
msg.post("#gameproxy", "load")
end
function final(self)
msg.post(".", "release_input_focus")
end
function on_message(self, message_id, message, sender)
if message_id == hash("add_coins") then
self.score = self.score + 20
gui.set_text(self.score_node, tostring(self.score))
elseif message_id == hash("game_over") then
self.GameOver = true
elseif message_id == hash("proxy_loaded") then
msg.post(sender, "enable")
end
end
function update(self)
if self.GameOver == true then
gui.set_text(self.game_over, tostring("GAME OVER"))
gui.set_text(self.retry, tostring("Touch to retry !"))
else
gui.set_text(self.game_over, tostring(""))
gui.set_text(self.retry, tostring(""))
end
end
function on_input(self, action_id, action)
if action_id == hash("touch") and action.pressed then
local button = gui.get_node("button")
if gui.pick_node(button, action.x, action.y) and self.pause == false then
self.pause = true
msg.post("#gameproxy", "set_time_step", {factor = 0, mode = 1})
else
self.pause = false
msg.post("#gameproxy", "set_time_step", {factor = 1, mode = 1})
end
elseif action_id == hash("escape") and action.pressed and self.pause == false then
self.pause = true
msg.post("#gameproxy", "set_time_step", {factor = 0, mode = 1})
else
self.pause = false
msg.post("#gameproxy", "set_time_step", {factor = 1, mode = 1})
end
end