How do I make a button with delayed action

Get help using Construct 2

Post » Sun Mar 22, 2015 9:51 am

I want that a button ( i am using sprites for that) will unlock a game feature only if it was touched for 3 consecutive seconds.
If user untouches the button nothing will happen

i tried a while loop but it got my game to be completely stuck. any idea on how to do so ?
B
8
S
2
Posts: 130
Reputation: 970

Post » Sun Mar 22, 2015 10:02 am

touch
object.counter


Event
Is touching object
subevent
every 1 second
action
add 1 to object.counter
subevent to every second
object.counter = 3
action
unlock feature
subevent to is touching object
is touching object (inverted)
action
object.counter = 0
Who dares wins
B
56
S
15
G
18
Posts: 1,846
Reputation: 17,793

Post » Sun Mar 22, 2015 10:20 am

Or:
on touch start & touching object: start timer once tag "delay" for 3.0 seconds
on touch end: stop timer tag "delay"
on timer "delay": do actions

might not detect when the touch leaves the object though, so might need an additional:
is not touching object button: stop timer tag "delay"
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 787
Reputation: 3,786

Post » Sun Mar 22, 2015 11:19 am

guys many thanks for the help, i guess i am not in the level yet of understanding your answers. is there a more siple way to understand it ?
B
8
S
2
Posts: 130
Reputation: 970

Post » Sun Mar 22, 2015 12:14 pm

Ours answers depict events and actions for event sheets.

I use that approach as answers as it helps those new to construct 2 in creating their own solutions, rather then having them handed an example file.
Who dares wins
B
56
S
15
G
18
Posts: 1,846
Reputation: 17,793

Post » Sun Mar 22, 2015 12:28 pm

ok, great i actually was able to use your tips to make it happen. Many Thanks
B
8
S
2
Posts: 130
Reputation: 970

Post » Sun Mar 22, 2015 12:39 pm

^_^

much obliged
Who dares wins
B
56
S
15
G
18
Posts: 1,846
Reputation: 17,793


Return to How do I....?

Who is online

Users browsing this forum: Husui, Phacanu and 7 guests