menu.gui_script 870 B

12345678910111213141516171819202122
  1. function init(self)
  2. msg.post(".", "acquire_input_focus") -- <1>
  3. end
  4. function on_input(self, action_id, action)
  5. if action_id == hash("touch") and action.released then -- <2>
  6. if gui.pick_node(gui.get_node("level1"), action.x, action.y) then -- <3>
  7. msg.post("proxy:/controller#controller", "show_level1") -- <4>
  8. elseif gui.pick_node(gui.get_node("level2"), action.x, action.y) then
  9. msg.post("proxy:/controller#controller", "show_level2")
  10. elseif gui.pick_node(gui.get_node("level3"), action.x, action.y) then
  11. msg.post("proxy:/controller#controller", "show_level3")
  12. end
  13. end
  14. end
  15. --[[
  16. 1. Acquire input focus for this script.
  17. 2. Check if a mouse click/screen touch is released.
  18. 3. Check if the mouse click/screen touch happened on top of any of the buttons.
  19. 4. Send a `show_level1` message to the controller script component in the `proxy` collection.
  20. --]]