I’m trying to debug my game as it no longer plays on HTML5 or Android. I’ve seeing in my menu for launching the game that the message when I click the play button is sent 3 times instead of once in the below code:
function init(self)
msg.post(".", "acquire_input_focus")
msg.post("@render:", "use_fixed_projection", { near = -1, far = 1 })
release_buttons(self)
self.pressed_button = nil
sound.play("#bgm2")
self.released = false
end
function final(self)
-- Add finalization code here
-- Learn more: https://defold.com/manuals/script/
-- Remove this function if not needed
end
function update(self, dt)
self.released = false
end
function on_message(self, message_id, message, sender)
-- Add message-handling code here
-- Learn more: https://defold.com/manuals/message-passing/
-- Remove this function if not needed
end
function release_buttons(self)
local node = gui.get_node("playgamebutton_depressed")
gui.set_enabled(node, false)
self.pressed_button = nil
end
function push_buttons(self, x, y)
local node = gui.get_node("playgamebutton")
if gui.pick_node(node, x, y) then
local node = gui.get_node("playgamebutton_depressed")
gui.set_enabled(node, true)
sound.stop("#bgm2")
self.pressed_button = hash("play_game")
return
end
end
function activate_pressed_button(self, x, y)
if self.pressed_button == hash("play_game") then
local node = gui.get_node("playgamebutton")
if gui.pick_node(node, x, y) then
if self.released == false then
msg.post(game_ref, hash("load_proxy"), { proxy = "#mainproxy", level = hash("tutchambers1") })
self.released = true
end
end
end
end
function on_input(self, action_id, action)
if action_id == hash("touch") then
push_buttons(self, action.x, action.y)
end
if action.released then
activate_pressed_button(self, action.x, action.y)
release_buttons(self)
end
end
The line “msg.post(game_ref, hash(“load_proxy”), { proxy = “#mainproxy”, level = hash(“tutchambers1”) })” is executed 3 times when I set a breakpoint there. I’m unsure why this is happening but the game crashes once the level loads on those platforms. PC is unaffected and I only see “ERROR:GAMESYS: Could not get the tile since the supplied tile was out of range” because I’m simply tolerating that as a result of there not being a tile_exists function for now.
Anyone seen this or can explain to me? I think it may be a result of action.released occurring multiple times after releasing the mouse left button (or touch screen press.) Shouldn’t this action only occur for one loop up the input?