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

function init(self)
	msg.post(".", "acquire_input_focus")

	local DURATION = 0.3
	local transition = transitions.create(gui.get_node("bg"))
	.show_in(transitions.slide_in_right, gui.EASING_LINEAR, DURATION, 0)
	.show_out(transitions.slide_out_left, gui.EASING_LINEAR, DURATION, 0)
	.back_in(transitions.slide_in_left, gui.EASING_LINEAR, DURATION, 0)
	.back_out(transitions.slide_out_right, gui.EASING_LINEAR, DURATION, 0)

	monarch.on_transition("window2", transition)
end

function on_input(self, action_id, action)
	if action_id == hash("touch") and action.released then
		if gui.pick_node(gui.get_node("button"), action.x, action.y) then
			monarch.back()
		end
	end
end

function on_message(self, message_id, message, sender)
	monarch.on_message(message_id, message, sender)
end