How do I simulate button clicking states with touch?

Get help using Construct 2

Post » Wed Sep 21, 2016 12:32 pm

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. :lol:

Thanks in advance! :)

Eliclax
B
14
S
4
Posts: 17
Reputation: 938

Post » Wed Sep 21, 2016 12:42 pm

Have you done something? It has a .capx to show us?
Hi I am Samuel :)

My google play
B
42
S
10
G
1
Posts: 126
Reputation: 3,278

Post » Wed Sep 21, 2016 1:31 pm

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"
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Wed Sep 21, 2016 4:12 pm

Eliclax wrote: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. :lol:

Thanks in advance! :)

Eliclax


You mean like this? :)

https://www.dropbox.com/s/96c0tmra36c1x ... .capx?dl=0
B
11
S
6
G
15
Posts: 256
Reputation: 9,207


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, R0J0hound, trance and 23 guests