mirror of
https://github.com/britzl/monarch.git
synced 2025-06-27 02:17:53 +02:00
38 lines
1.5 KiB
Plaintext
38 lines
1.5 KiB
Plaintext
local monarch = require "monarch.monarch"
|
|
|
|
function init(self)
|
|
msg.post(".", "acquire_input_focus")
|
|
self.play = gui.get_node("play_button")
|
|
self.back = gui.get_node("back_button")
|
|
self.play_position = gui.get_position(self.play)
|
|
self.back_position = gui.get_position(self.back)
|
|
gui.set_position(self.back, self.back_position + vmath.vector3(0, 1000, 0))
|
|
gui.set_position(self.play, self.play_position + vmath.vector3(0, 1000, 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"))
|
|
elseif gui.pick_node(self.back, action.x, action.y) then
|
|
print("back")
|
|
monarch.back()
|
|
end
|
|
end
|
|
end
|
|
|
|
function on_message(self, message_id, message, sender)
|
|
if message_id == hash("transition_show_in") or message_id == hash("transition_back_in") then
|
|
gui.animate(self.play, gui.PROP_POSITION, self.play_position, go.EASING_INQUAD, 0.6, 0, function()
|
|
msg.post(sender, "transition_done")
|
|
end)
|
|
gui.animate(self.back, gui.PROP_POSITION, self.back_position, go.EASING_INQUAD, 0.6)
|
|
elseif message_id == hash("transition_show_out") or message_id == hash("transition_back_out") then
|
|
gui.animate(self.play, gui.PROP_POSITION, self.play_position + vmath.vector3(0, 1000, 0), go.EASING_INQUAD, 0.6, 0, function()
|
|
msg.post(sender, "transition_done")
|
|
end)
|
|
gui.animate(self.back, gui.PROP_POSITION, self.back_position + vmath.vector3(0, 1000, 0), go.EASING_INQUAD, 0.6)
|
|
end
|
|
end
|