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.
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
Thanks. But how can I check if the user's finger was touching the screen, from beginning to end of the movement?
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
Develop games in your browser. Powerful, performant & highly capable.
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.
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)
Thank you so much for your time.
I tried this script below, but something is wrong and I don't know what is. Could you check for me?
Sorry. I fixed the URL problem. Any help?
I made a little prototype for you:
https://dl.dropboxusercontent.com/u/238 ... order.capx
Thank you very much, andreyin!
It's exactly what I needed.
I would just like to understand the use of the "append" (str (sprite.IID)). Could you?
When you "append" something to a text object, it will add what you want after the current text.
If you have a text object with "Hello" written on it and append " world" after it (with the space), you would get "Hello world".
If you have a text object with "Hello" written on it and used SET TEXT with " world", the text would erase and become " world".
The sprite IID is the instance ID that it has when it's created. If you notice, all the sprites with numers are the same sprite, just with different animations. When the game starts it loads these sprites one by one, and each one has a single IID, from 0 to 3. The str() expression converts this number into a string, and the append adds it to the text object.
IID has nothing to do with UID, right?
In this case, the frame numbers are associate to IID?
If I intend to create the sprites when the game starts, instead to do this manually, the only thing I have to do is change the frame number for each one (randomly for example)?
IIDs are only for the same object - UIDs are for all the objects from the entire game.
Yeah, you could make something like "on start of layout -> for 0 to 3 -> Create Sprite at random positions -> Set sprite frame to (loopindex)
Thank you, — You really helped me.