How do I check a sequence?

Get help using Construct 2

Post » Tue Feb 24, 2015 11:50 am

In a simulation that I will create, the player must pass the finger in the points distributed on the screen, obeying the sequence. I need to find a way to check if the sequence is right and if the finger was in contact with the screen all the time. Thanks.
B
68
S
13
G
2
Posts: 989
Reputation: 6,864

Post » Tue Feb 24, 2015 2:01 pm

You can use a string : each point has an ID, when touch is over the point, add the ID to the string.
If the touch ends, reset the string to "".

At each point check the sting is correct or not, should work :)
B
6
S
1
Posts: 45
Reputation: 509

Post » Tue Feb 24, 2015 5:19 pm

Thanks. But how can I check if the user's finger was touching the screen, from beginning to end of the movement?
B
68
S
13
G
2
Posts: 989
Reputation: 6,864

Post » Tue Feb 24, 2015 7:00 pm

If the user touch the screen all along the movement, the string will be correct. If the user get off the screen, the string will be reinitialised, then it wont be correct at the end.

Example : your checkpoints are A B C D E F.
Correct case : The user starts touching the screen, go through A (=> string = A), trhough B (=> string = AB)... through F => string = ABCDEF ==> correct
Incorrect case : The user starts touching the screen, go through A (=> string = A), trhough B (=> string = AB), then dont touch the screen between B & C (==> string = ""), then touch again and go through C (=> string = C) ... through F ==> string = CDEF ==> incorrect

:)
B
6
S
1
Posts: 45
Reputation: 509

Post » Tue Feb 24, 2015 8:03 pm

I think I understood. "String" is a variable that I need to check every tick, correct? If not, can you give me a example? CAPX is not necessary, only some command lines.
B
68
S
13
G
2
Posts: 989
Reputation: 6,864

Post » Tue Feb 24, 2015 9:22 pm

That's right.
You can check it at each checkpoint (and not every tick to not waste memory). With previous example, if the user is touching "C", the variable string should be "ABC", if not, you can alert the user, or game over (or whatever) :)
B
6
S
1
Posts: 45
Reputation: 509

Post » Tue Feb 24, 2015 9:31 pm

Thank you so much for your time.
B
68
S
13
G
2
Posts: 989
Reputation: 6,864

Post » Fri Feb 27, 2015 3:06 pm

@Adisma

I tried this script below, but something is wrong and I don't know what is. Could you check for me?

http://prntscr.com/6ahq0j
B
68
S
13
G
2
Posts: 989
Reputation: 6,864

Post » Wed Mar 04, 2015 10:01 am

Sorry. I fixed the URL problem. Any help?
B
68
S
13
G
2
Posts: 989
Reputation: 6,864

Post » Wed Mar 04, 2015 11:59 am

I made a little prototype for you:

https://dl.dropboxusercontent.com/u/238 ... order.capx
B
115
S
38
G
40
Posts: 821
Reputation: 27,289

Next

Return to How do I....?

Who is online

Users browsing this forum: Aluna and 7 guests