How do I disable layer input ?

Get help using Construct 2

Post » Mon Oct 07, 2013 8:50 pm

Hello, I've encountered the following problem:



I have a Pause Screen on a layer that is set to be invisible until the pause button is pressed. I also have a lot of objects in my game that can be touched. The problem is that I can touch the objects and the buttons regardless if the layer is visible or not.

I've found this workaround:
http://www.scirra.com/forum/suggestion-layer-input-option_topic65704.html
But I would like to not be forced to add another condition (check if Pause Menu is visible) to any touchable object from my game.
B
49
S
15
G
6
Posts: 536
Reputation: 7,199

Post » Mon Oct 07, 2013 9:37 pm

Add all the touch events to a group then toggle it inactive when you show the pause menuEncryptedCow2013-10-07 21:50:12
B
47
S
14
G
7
Posts: 603
Reputation: 8,151

Post » Tue Oct 08, 2013 5:10 am

I've been running into this issue as well. There must be an easier way to deal with it. It's very annoying and seems like there should be an easy fix for it.
B
62
S
20
G
56
Posts: 1,077
Reputation: 36,021

Post » Tue Oct 08, 2013 5:22 am

Create a variable we'll call it "canTouchDis", and set its initial value to "stop".
Now make an on input event like on clicked, or on touched object, and then make a sub event that compares "canTouchDis" ="hammerTime", do the hammer dance.

Then all you would need to do is make an event that changed stop to hammerTime in another event.
Image ImageImage
B
172
S
50
G
184
Posts: 8,444
Reputation: 116,107

Post » Tue Oct 08, 2013 8:10 am

Taking my hat of and doing the hammer dance for @newt ..

I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Oct 08, 2013 7:05 pm

Ok, so there is no direct way to do this, only workarounds ?

In that case I will probabbly use the Group Events method since I like to have a "clean code".

Still, thanks @newt for your method. I'm sure that will come in handy
B
49
S
15
G
6
Posts: 536
Reputation: 7,199

Post » Tue Dec 16, 2014 12:56 pm

I ran into the same problem but I couldn't use the Group Events method (I learned something new though!). I use the same code for buttons that are on or not on the pause menu, so I would end up either disabling all the buttons or none of them.

If anyone runs into this too, my workaround is to add the following conditions:

On touched <object>
AND <object> is visible
AND Layer <object.LayerName> is visible

This way, I don't have to be specific about what menu is showing or not (i.e. I can reuse the code in other projects.).

I added my two cents to http://www.scirra.com/forum/suggestion- ... 65704.html so I'm hoping we don't have to deal with these types of workarounds in the future. (Argh, I just realized there's a place I missed adding this workaround.)
B
4
Posts: 2
Reputation: 204


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 32 guests