Disable mouse click on object

Get help using Construct 2

Post » Mon Apr 16, 2012 3:09 pm

Hi,

Is there a way to disable a mouse click on an object based upon the value of a variable?

E.g. Disable mouse click on object X in case var_a = 0

Your help will be much appreciated.

Regards,


SPX
B
8
S
3
G
4
Posts: 8
Reputation: 2,544

Post » Mon Apr 16, 2012 3:11 pm

Maybe there's a better way, but you could put an invisible object on top of the object in question, and destroy/spawn it depending on the variable. Then apply the mouseclick events to the invisible object.
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Mon Apr 16, 2012 3:40 pm

Thank you, this worked like a charm!
B
8
S
3
G
4
Posts: 8
Reputation: 2,544

Post » Sun Feb 16, 2014 3:09 pm

how is posible to do that?
when i put invisible object over some i dont want to be clicked, still ghet clicked
even i put him in new layer and still same
B
5
Posts: 13
Reputation: 281

Post » Sun Feb 16, 2014 7:17 pm

anyone help?
B
5
Posts: 13
Reputation: 281

Post » Fri Oct 24, 2014 6:00 am

ajvar23 wrote:how is posible to do that?
when i put invisible object over some i dont want to be clicked, still ghet clicked
even i put him in new layer and still same


The invisible object are not meant to block the object under it, it's just like a hit area / hittest, so give your events to that invisible object, not the object under it.

And, if you want to activate/deactivate the mouse click logic, just destroy/spawn that invisible object. Or, if you want more advance, you can add your own (instance) variable, e.g: disabled. Then, in your mouse click event, add another event condition to check if it is not disabled.
B
4
Posts: 1
Reputation: 302


Return to How do I....?

Who is online

Users browsing this forum: Zebbi and 21 guests