If In Touch for More Then 2 Seconds?

Get help using Construct 2

Post » Thu Sep 12, 2013 10:51 pm

Hey folks, trying to grasp the idea on how to find out to do the following:

+If player touches and holds screen(in touch) for more then 2 second...

Does construct allow in touch to be calculated by how long the player holds down on the screen.

I am trying to do the following:

+ If player or holds down screen for more then 2 seconds, then gets a burst of speed to that position.


Or... the other way..

+ If player taps on screen 2x (quickly.. like double tap). then the player gets boost.

Any ideas on how to do either of these.

Thanks
B
5
Posts: 11
Reputation: 247

Post » Thu Sep 12, 2013 11:08 pm

Use the system expression 'time' for both.

[code]
+ Player touches -> Set global 'timestamp' to time
+ Is in touch
+ time - timestamp >= 2
    trigger once             -> give burst
[/code]

[code]
+ Player touches
+ global 'doubletap' = 0 -> Set global 'timestamp' to time
                             Set global 'doubletap' to 1
+ else
    + time - 'timestamp' < 0.3 (or however fast you like) -> give boost
[/code]

Just make sure you reset the globals correctly and at the right times.tulamide2013-09-12 23:08:31
Image
B
24
S
8
G
10
Posts: 1,821
Reputation: 8,279

Post » Thu Sep 12, 2013 11:28 pm

Thank you SOOOO Much!

This worked perfectly.
I am still amazed how you came up with this in your head.
However you did it, i am very grateful for the help.
B
5
Posts: 11
Reputation: 247

Post » Thu Sep 12, 2013 11:44 pm

[QUOTE=dreambotstudios]I am still amazed how you came up with this in your head.[/QUOTE] Most of the time I wonder myself I'm glad I could be of help.
Image
B
24
S
8
G
10
Posts: 1,821
Reputation: 8,279

Post » Thu Sep 12, 2013 11:59 pm

Knowing the system expressions can really help out a lot when learning a new programming language.

https://www.scirra.com/manual/126/system-expressions
B
101
S
32
G
11
Posts: 1,546
Reputation: 21,667


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 33 guests