Hi guys,
I’m trying to trigger an event when the player touches two virtual buttons at the same time but can’t seem to find any tutorials on it. Hope you guys can help me out.
Basically my game has two virtual buttons; L and R
- pressing L will make the character move left.
- pressing R will make the character move right.
- pressing L and R together will make the character jump <-- this is where I’m having problems. I don’t know how to check if both buttons were pressed.
Thanks in advance.
Below is my code
-- L Button Declarations etc LButton.myName = "leftSquare" LButton:addEventListener("touch", touchControls) -- R Button Declarations etc RButton.myName = "rightSquare" RButton:addEventListener("touch", touchControls) function touchControls(event) if (event.phase == "began") then if (event.target.myName == "leftSquare") then -- Character Moving Left elseif (event.target.myName == "rightSquare") then -- Character Moving Right end end if (event.phase == "ended") then -- Stop Character Movement end return true end