I am testing Defold. I am trying to recognize mouse clicks. I have a game object with the following script. I only get mouse position, no pressed or released. Also, I can get key clicks (I removed that for this test).
– t_to_str converts a LUA table to a string.
function t_to_str(t)
s = ""
for k, v in pairs(t) do
s = s … tostring(k) … “:” … tostring(v) … " "
end
return s
end
function init(self)
msg.post(".", “acquire_input_focus”)
end
function final(self)
msg.post(".", “release_input_focus”)
end
function on_input(self, action_id, action)
if action.pressed then
print("on_input: pressed " … t_to_str(action))
elseif action.released then
print("on_input: released " … t_to_str(action))
else
print("on_input: weird " … t_to_str(action))
end
end