On_input does not run (SOLVED)

Hi, i am building a simple minsweeper and i want the squares to in some way react on clicks. But the squares (tile.go) does not react on any sort of input.
The on_input code is this:
`

function on_message(self, message_id, message, sender)
print(action_id)
if message_id == hash(“click”) then
pprint(“Click”)
if ismine == 1 then
pprint(“Explode”)
go.animate(“Explode”)
end
end
end`

Did you add

msg.post(".", "acquire_input_focus")

to init?

Also make sure that you had configured action “click” in input/game.input_binding

You are using the on_message function and not the on_input function in the code you shared.

3 Likes

Try

function on_input(self, action_id, action)
    print(action_id)
    if action_id == hash("click") then
        print("Click")
        if ismine == 1 then
            print("Explode")
        end
    end
end

Thanks so much. I <3 Defold forum!!!

3 Likes