Hi !
I have a problem because I don’t know how to detect (mobile version in html) an event when a user holds down for example the “left” button and clicks “jump”. It always either detects left or jump for me, never both at the same time,
I reviewed an example.
http://britzl.github.io/publicexamples/virtual_gamepad/index.html
Here it is the same, I can control the rocket, but I can’t shoot at the same time. Is this a problem of html version ?
There is my code
function on_input(self, action_id, action)
local up_node = gui.get_node("up")
local left_node = gui.get_node("left")
local right_node = gui.get_node("right")
if action_id == hash("Mtouch") then
if action.touch then
for _,touchpoint in ipairs(action.touch) do
if gui.pick_node(left_node, action.x, action.y) then
if action.pressed then
msg.post("/player/player#player", "tap_left", { action = -1 })
elseif action.released then
msg.post("/player/player#player", "tap_left", { action = 0 })
end
end
if gui.pick_node(right_node, action.x, action.y) then
if action.pressed then
msg.post("/player/player#player", "tap_right", { action = 1 })
elseif action.released then
msg.post("/player/player#player", "tap_right", { action = 0 })
end
end
if gui.pick_node(up_node, action.x, action.y) then
if action.pressed then
msg.post("/player/player#player", "tap_up", { action = 1 })
elseif action.released then
msg.post("/player/player#player", "tap_up", { action = 0 })
end
end
end
end
end
end