Hey guys! Never worked with a GUI before so I have no clue what I’m doing. I’m loosely following this tutorial:
http://www.gamefromscratch.com/post/2017/02/21/Defold-Engine-Tutorial-Series-UI-Programming.aspx
What I’m trying to do is get a response from my code when I click on a node in my GUI. The GUI is built. Its placed in a game object that’s inside main.collection. It has a box node with the id “box” and a text node nested inside. My input “mouse-button-left” is bound to the action “trigger_click”. The .gui_script is linked to the gui. Heres my code:
function init(self)
msg.post(".","aquire_input_focus")
end
function on_input(self, action_id, action)
if (action_id == hash("trigger_click") and action.released == true) then
if (gui.pick_node(gui.get_node("box"),action.x,action.y)) then
print("GUI has been clicked")
end
end
end
When I run the project the print doesn’t appear in the console. I feel like there’s a really simple solution but I’ve been wrapping my head around this for a while and cant find any mistakes. Any ideas?