Two button event. Help me

i have three button.

  1. attack
  2. left
  3. right

how to perform when i touch right+attack (my object will attack the right side)

or

when i touch left+attack (my object will attack the left side)

please someone help :frowning:

You can define a simple flag to do that on top of the scene file.

local isRightPressed = false local isLeftPressed = false

After that, you need to change those flags when that button is pressed.

local function handleButtons(event) if (event.phase == "began") then if (event.target.id == "left") then isRightPressed = false isLeftPressed = true elseif (event.target.id == "right") isLeftPressed = false isRightPressed = true end elseif (event.phase == "ended") then isRightPressed = false isLeftPressed = false end return true end

After that, you will need to check those flags when the attack button is pressed and act accordingly.

@bgmadclown: aww… thx for replay sir. Sry im late for this :slight_smile:

ill try this soon…

You can define a simple flag to do that on top of the scene file.

local isRightPressed = false local isLeftPressed = false

After that, you need to change those flags when that button is pressed.

local function handleButtons(event) if (event.phase == "began") then if (event.target.id == "left") then isRightPressed = false isLeftPressed = true elseif (event.target.id == "right") isLeftPressed = false isRightPressed = true end elseif (event.phase == "ended") then isRightPressed = false isLeftPressed = false end return true end

After that, you will need to check those flags when the attack button is pressed and act accordingly.

@bgmadclown: aww… thx for replay sir. Sry im late for this :slight_smile:

ill try this soon…