How do I run a On tap only once when using conditions

0 favourites
  • 3 posts
From the Asset Store
Full game Construct 2 and Construct 3 to post on Google Play
  • Hey guys,

    I had this problem a few years back and i used a workaround back then but i forgot what i did.

    I was wondering if there is a clean solution for taps with specific conditions.

    My code is as following:

    On tap > Next

    --- IF variable = 1 > Do action 1

    --- IF variable = 2 > Do action 2

    --- IF variable = 3 > Do action 3

    The problem is that when you tap "Next" it will do all "IF'S". So instead of checking the condition and doing it it actually starts a chain.

    After the first click the first action is true. Than the second action will be true after that. Than the 3th etc. But instead of only running it once it will do all actions which is pretty weird i guess since i only tapped once.

    Any solution to this without creating a weird workaround?


  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Move second condition where you comparing a variable to a sub-event and use Else:

    On tap gesture on btn
        System avatarPicked=3  -> .........
        System avatarPicked=4  -> .........
        System avatarPicked=13  -> .........
    Or you can actually compress all this code into a single expression using [url=]ternary operator[/url]:
    avatarPicked= (avatarPicked=3 ? 4 : avatarPicked=4 ? 13 : avatarPicked=14 ? 21 : 0)
    avatars Set animation frame to (avatarPicked)
  • dop2000 Darn i knew i was close i did it like that the first try but without the "ELSE".

    Should'v thought of that.

    Thanks for the info!

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