How do I simulate button clicking states with touch?

0 favourites
  • 4 posts
From the Asset Store
State Machine
$10.99 USD
State Machine is a great tool for managing the state of anything in your game.
  • Go ahead and try the following with the search button, although it's not entirely accurate: it doesn't follow the first rule correctly.

    We'll call the original state of the search button A, and the pressed (or in the case of the search button, hovered) state, B.

    If you click down on the search button, it changes from A to B. (well, in the case of the search button, if you hover over the search button, it changes to B, but I think usually, there's a different state for hovering over a button and clicking on the button)

    If you move your mouse away from the search button while still keeping the left click pressed, it changes back into state A, and if you then move your mouse back over the search button, it changes to state B again.

    If you release the left click button while your mouse is on the search button, it does the action (which is to search, in our case).

    If you release the left click button while your mouse is not on the search button, it turns back into state A.

    My question is, how can I simulate this with touch on Construct 2? (Obviously, there is no hover 'state', but there will be a touched state and a non-touched state)

    If my model of button clicking states isn't accurate, you can correct it. It's just based on what I've observed.

    Thanks in advance!

    Eliclax

  • Have you done something? It has a .capx to show us?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Give the button a instance variable 'state' ... lets make it a string so we can do it with one 'state' variable.

    States are "None", "Hover" and "Clicked"

    I assume the button is a sprite and you gave them 3 animations, "None", "Hover" and "Clicked"

    Clicked should have at least 5 animation frames.

    Now.

    On touched Button

    state = "None"

    ........ Set state to "Hover"

    ........ Set animation to "Hover"

    Else

    ........ Set state to "None"

    ........ Set animation to "None"

    On taped on Button

    ........ Set state to "Clicked"

    ........ Set animation to "Clicked"

    On animation "Clicked" ended

    ....... Set animation to "None"

  • Go ahead and try the following with the search button, although it's not entirely accurate: it doesn't follow the first rule correctly.

    We'll call the original state of the search button A, and the pressed (or in the case of the search button, hovered) state, B.

    If you click down on the search button, it changes from A to B. (well, in the case of the search button, if you hover over the search button, it changes to B, but I think usually, there's a different state for hovering over a button and clicking on the button)

    If you move your mouse away from the search button while still keeping the left click pressed, it changes back into state A, and if you then move your mouse back over the search button, it changes to state B again.

    If you release the left click button while your mouse is on the search button, it does the action (which is to search, in our case).

    If you release the left click button while your mouse is not on the search button, it turns back into state A.

    My question is, how can I simulate this with touch on Construct 2? (Obviously, there is no hover 'state', but there will be a touched state and a non-touched state)

    If my model of button clicking states isn't accurate, you can correct it. It's just based on what I've observed. <img src="{SMILIES_PATH}/icon_lol.gif" alt=":lol:" title="Laughing">

    Thanks in advance! <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    Eliclax

    You mean like this? <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    https://www.dropbox.com/s/96c0tmra36c1x ... .capx?dl=0

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