Best way to prevent accidental button click?

0 favourites
  • 13 posts
From the Asset Store
Click! Click! 136 click sounds for your video games or media projects
  • I have a continue button that switches out the components on the screen with a new start button. However, since the Start button appears exactly where the continue button is, the OnTouchEnd triggers the click for the Start button as well. How do I prevent OnTouchEnd to only trigger for the Continue button and not the next button that shows up under it?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • There probably is a way to pick the top instance ( even may be called pick top ), but I usually do this stuff by having the button that is supposed to be underneath the first one off screen, same x coordinates, but something like -999 Y. Then when on touch end triggers, move top button to - 999 y, and move the other one to whatever Y it is supposed to be.

  • You can bound it with your own rules :

    - Set it invisible when inactive, then on touched it, if it visible, you do the action

    - Do the same if you want to use Opacity

    - Have global variable to cover all your action

    Ex : gamestate = 0 --> you can touch Start Only

    gamestate = 1 --> you can touch Continue Only

    - Or any rule which you can set to make you feel convenience when doing your game.

    Cheers.

  • The easy/hacky way is to add "wait 0 seconds" before you switch out the buttons. Wait 0 seconds is equal to "wait one tick"

  • "On tap object"

  • The easy/hacky way is to add "wait 0 seconds" before you switch out the buttons. Wait 0 seconds is equal to "wait one tick"

    This did the trick

  • I create a global value called "WAIT" and have an event that If WAIT >0 then subtract 1 from wait every 0.1 seconds.

    For every check of any button being pressed I add the condition that 'WAIT"=0 and in the action it sets WAIT to 5

    This way, the game UI can never accidentally accept a double input just because the finger is still down when the screen switches or a new button appears. It gives the user time to have lifted their finger or thumb off the screen or unclick the mouse or controller button.

  • No no no, add a function that calls a function that calls another function.

    Be sure and put the calls in a group on an includes sheet.

  • No no no, add a function that calls a function that calls another function.

    Be sure and put the calls in a group on an includes sheet.

    newt why you always making strange comments on construct forums? You did the same thing on my post many months back.

  • "On tap object"

  • newt why you always making strange comments on construct forums? You did the same thing on my post many months back.

    Newt is our very own veteran forum troll.

    Also newt, on tap object does not produce the result op asked for.

  • Yes it does.

    Your events are out of order.

    dropbox.com/s/bkd6szzb4vr2szq/tapobject.c3p

  • Yes it does.

    Your events are out of order.

    https://www.dropbox.com/s/bkd6szzb4vr2szq/tapobject.c3p?dl=0

    touché, though it might be an annoying thing to reorder depending on how big the project is/how it is generally ordered

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)