How do I change sprite colour depending on touch speed

Get help using Construct 2

Post » Tue May 13, 2014 11:27 am

Hi everyone,

Could be a really simple question but it has me stumped.

I would like to change the colour of a sprite depending on how fast the user taps the screen.

For example:

no taps - white sprite
lots of taps - red sprite

I don't have a problem changing the colour of the sprite, but how can I measure the frequency of the users taps?

Thanks!
B
13
S
6
Posts: 130
Reputation: 1,553

Post » Tue May 13, 2014 11:43 am

Do this:

System Event -> On every 0.5 seconds (for example) & Is Object being touched.

If it misses one it will stay white. Change the timing to get he frequency that you need.

Let me know if it works for you.

Cheers!
B
24
S
4
G
1
Posts: 177
Reputation: 1,827

Post » Tue May 13, 2014 11:54 am

Hi henriquesv,

thanks for your advice - I just tried our your logic and it works - just not quite how I imagined it!

What I am looking for is a little more open ended. By that I mean instead of targeting a specific touch frequency, I would like the sprite to change colour gradually as the user taps faster and faster.

Any ideas?

Thanks again for helping out!
B
13
S
6
Posts: 130
Reputation: 1,553

Post » Tue May 13, 2014 11:55 am

Try this capx. You also have to remember to check if touch has been released... otherwise the player would cheat =)
You do not have the required permissions to view the files attached to this post.
B
24
S
4
G
1
Posts: 177
Reputation: 1,827

Post » Tue May 13, 2014 11:56 am

Hummm I see... let me think about it!
B
24
S
4
G
1
Posts: 177
Reputation: 1,827

Post » Tue May 13, 2014 11:58 am

You could do this:

Set the timer to minimum period (increase frequency) and count how many touches it gets in a larger amount of time.
B
24
S
4
G
1
Posts: 177
Reputation: 1,827

Post » Tue May 13, 2014 11:59 am

For instance:

Timer 1 (0.01s): check if the touch has been released and if it is touching. Add 1 to the counter.
Timer 2 (0.5s): check how many touches happened and set this number to a color scale; clear counter;

=)
B
24
S
4
G
1
Posts: 177
Reputation: 1,827

Post » Tue May 13, 2014 12:04 pm

Hi henriquesv,

thank you very much for your help, that looks perfect!

I will give that a try and let you know how I go (or if I need any more assistance =) .

thanks again!
B
13
S
6
Posts: 130
Reputation: 1,553


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 17 guests