local monarch = require "monarch.monarch"
local transitions = require "monarch.transitions.gui"

function init(self)
	msg.post(".", "acquire_input_focus")
	self.play = gui.get_node("play_button")
	self.back = gui.get_node("back_button")
	
	self.transition = transitions.in_right_out_left(gui.get_node("root"), 0.6, 0)
end

function on_input(self, action_id, action)
	if action_id == hash("touch") and action.released then
		if gui.pick_node(self.play, action.x, action.y) then
			print("play")
			monarch.show(hash("game"), nil, { level = 1 }, function()
				print("showing game done")
			end)
		elseif gui.pick_node(self.back, action.x, action.y) then
			print("back")
			monarch.back(function()
				print("back from pregame done")
			end)
		end
	end
end

function on_message(self, message_id, message, sender)
	self.transition.handle(message_id, message, sender)
end
