I honestly don’t see any problem. I added some prints to your code. And os.time() to see roughly at what time things happen. I also changed the 10 second repeating timer to 4 seconds so that I don’t have to wait as long:
function init(self)
msg.post(".", "acquire_input_focus")
local position = vmath.vector3(480, 320, 0)
local size = vmath.vector3(200, 100, 0)
self.button = gui.new_box_node(position, size)
print(os.time() .. " init")
gui.set_enabled(self.button, false) -- (1)
timer.delay(4, true, function()
print(os.time() .. " outer repeating timer has triggered")
gui.set_enabled(self.button, true) -- (2)
timer.delay(2, false, function()
print(os.time() .. " inner timer has triggered")
gui.animate(self.button, "scale", vmath.vector3(0, 0, 0), gui.EASING_LINEAR, 2, 0, function()
print(os.time() .. " inner animate done")
gui.set_enabled(self.button, false) -- (3)
gui.set_scale(self.button, vmath.vector3(1, 1, 1))
end)
end)
end)
end
function on_input(self, action_id, action)
if action_id == hash("touch") and gui.pick_node(self.button, action.x, action.y) then
print(os.time() .. " click and hide")
gui.set_enabled(self.button, false) -- (4) This is the line that triggers the bug. Removing this or replacing (1), (2), (3) and (4) with gui.set_visible fixes the problem
gui.new_text_node(vmath.vector3(480, 150, 0), "Button clicked")
end
end
Output:
DEBUG:SCRIPT: 1774939788 init
DEBUG:SCRIPT: 1774939792 outer repeating timer has triggered
DEBUG:SCRIPT: 1774939794 inner timer has triggered
DEBUG:SCRIPT: 1774939796 outer repeating timer has triggered
DEBUG:SCRIPT: 1774939796 inner animate done
DEBUG:SCRIPT: 1774939798 inner timer has triggered
DEBUG:SCRIPT: 1774939800 outer repeating timer has triggered
DEBUG:SCRIPT: 1774939802 inner animate done
DEBUG:SCRIPT: 1774939802 inner timer has triggered
DEBUG:SCRIPT: 1774939804 outer repeating timer has triggered
DEBUG:SCRIPT: 1774939805 click and hide
DEBUG:SCRIPT: 1774939806 inner timer has triggered
DEBUG:SCRIPT: 1774939808 outer repeating timer has triggered
DEBUG:SCRIPT: 1774939809 click and hide
DEBUG:SCRIPT: 1774939810 inner timer has triggered
DEBUG:SCRIPT: 1774939812 outer repeating timer has triggered
DEBUG:SCRIPT: 1774939814 inner animate done
DEBUG:SCRIPT: 1774939814 inner timer has triggered
DEBUG:SCRIPT: 1774939816 outer repeating timer has triggered
From the looks of it the inner timer keeps triggering as expected.
One thing to note is that you are not checking action.pressed which means that your button logic will run multiple times in on_input.