Disable touch

Get help using Construct 2

Post » Wed Aug 07, 2013 5:34 pm

Hello,
when I touch some sprite on my mobile device (and something happens) I want that touch function to be disabled after the first touch...

For example, when I touch some button -> object starts to rotate -> here I dont want that button to be touched again, simply I just want to disable it after the first touch input.

How to do it?trance2013-08-07 17:35:10
B
13
S
4
Posts: 105
Reputation: 1,503

Post » Wed Aug 07, 2013 7:32 pm

nobody knows ? is it even possible?
B
13
S
4
Posts: 105
Reputation: 1,503

Post » Wed Aug 07, 2013 7:39 pm

Do you have a capx for me?

and if you're talking about what I think u are, sure its possible
B
9
S
2
G
2
Posts: 59
Reputation: 1,024

Post » Wed Aug 07, 2013 7:43 pm

You can do that in many ways.

One way is to create a global variable you set to 1 the first time its pressed.

On the touch event just check for if that variable is 0

You could also put the touch event in a group and then disable the group once the button is pressed.
B
20
S
6
G
4
Posts: 347
Reputation: 4,451

Post » Sun Oct 13, 2013 5:52 am

[QUOTE=cvp] You can do that in many ways.

One way is to create a global variable you set to 1 the first time its pressed.

On the touch event just check for if that variable is 0

You could also put the touch event in a group and then disable the group once the button is pressed.[/QUOTE]

Thanks, that's what I need.
B
37
S
4
G
2
Posts: 45
Reputation: 3,997

Post » Mon Apr 21, 2014 7:26 pm

I used the search and I have a similar problem.

I have a button and i need when the button is touched to disable a second button.

There is no way to disable this second button?

How do you do the event group disable?
B
31
S
13
G
5
Posts: 355
Reputation: 4,558

Post » Tue Apr 22, 2014 1:49 am

A little explication would be very appreciated.
B
31
S
13
G
5
Posts: 355
Reputation: 4,558

Post » Tue Apr 22, 2014 2:25 am

You have to figure a way for a second touch function to not be acted upon by your events. Remember, the events run every tick, so the only way to ignore a touch event is to add a condition to the touch trigger so that your code can identify when the trigger has been actioned before. You can't simply disable touch on an object, it doesn't work like that. There really are a lot of ways you could do this.

One simple way is to add an object boolean to your sprite - something like object.Touched. Check that the boolean is false during your touch trigger and then set it to true during the subsequent commands so that the touch event trigger cannot fire again.

Also remember that if you have mouse input set to yes on the touch object then that can also trigger two touch events on some iOS and Android devices.
I only occasionally visit - I'm learning C# for Unity, but c2 is still a respectable game engine imo....
B
73
S
19
G
66
Posts: 2,198
Reputation: 42,188


Return to How do I....?

Who is online

Users browsing this forum: Alvaro2 and 15 guests