How do I disable TOUCH for specific objects?

Get help using Construct 2

Post » Sat May 14, 2016 10:12 pm

Hey guys.

I'm currently completing the MAIN MENU for my game.

For the options, I simply spawn a window on top of the title screen with it's own buttons for different functions such as switching sound on and off, selecting difficulty...

My problem is that I seemingly can't disable the other buttons currently on the screen. I tried the "disable collisions" command but whenever I touch the window at the spot where say the NEW GAME button is, the layout still switches to the actual game layout. I thought maybe the collisions are disabled only while I'm pressing the actual menu button so I tried creating a boolen for disabling and enabling collisions but it doesn't seem to work.

Now I'm left with simply destroying all buttons upon spawning the window and then re-creating the buttons when I exit the options window.

That said, is this more convenient Memory-Wise for four sprites to be destroyed and re-created every time I access the OPTIONS window? It's only four sprites so even if it weren't, I don't think it'll be that big of a problem. If it is, then I guess I'll keep the current setup.

Thanks!
Image Image Image
B
29
S
11
G
27
Posts: 729
Reputation: 16,995

Post » Sat May 14, 2016 11:38 pm

For this, you could use a variable on the buttons. Let's call it "allowTouch".

In your touch event that checks for which button you are pressing on, you will also check for this variable "allowTouch". If "allowTouch" is 1, you will do everything you desires. If not, don't do anything.

For collision enabling, that is for object collision check, not touch control check. So what you have been doing doesn't have any affect on touch control.
I got a game that you multiply, breath fire with two heads and brawl foes to oblivion with your clones: http://www.newgrounds.com/portal/view/660664 (use Chrome on Windows for best performance)

My sites:
http://twinblazar.deviantart.com
http://twinblazar.newgrounds.com
https://twitter.com/twinblazar
http://www.pixiv.net/member.php?id=15072448
B
30
S
11
G
11
Posts: 411
Reputation: 8,459

Post » Sat May 14, 2016 11:38 pm

But yes, destroying all the unneeded buttons work too.
I got a game that you multiply, breath fire with two heads and brawl foes to oblivion with your clones: http://www.newgrounds.com/portal/view/660664 (use Chrome on Windows for best performance)

My sites:
http://twinblazar.deviantart.com
http://twinblazar.newgrounds.com
https://twitter.com/twinblazar
http://www.pixiv.net/member.php?id=15072448
B
30
S
11
G
11
Posts: 411
Reputation: 8,459

Post » Sun May 15, 2016 3:29 am

How about:

Enable the touching if the button is opaque (Opacity = 100) - If Button is touched and Button.Opacity = 100 then Do Something...
B
103
S
24
G
11
Posts: 695
Reputation: 12,884

Post » Sun May 15, 2016 5:29 am

Enable the touching if the button is opaque (Opacity = 100) - If Button is touched and Button.Opacity = 100 then Do Something...


It's not a good practice, but yes, that... also works, but don't forget that the button is now relying on Opacity to function properly. If in the future, you somehow have to adjust opacity for whatever reason outside of this scope, you better take care of changes with respect to buttons relying on opacity to work.
I got a game that you multiply, breath fire with two heads and brawl foes to oblivion with your clones: http://www.newgrounds.com/portal/view/660664 (use Chrome on Windows for best performance)

My sites:
http://twinblazar.deviantart.com
http://twinblazar.newgrounds.com
https://twitter.com/twinblazar
http://www.pixiv.net/member.php?id=15072448
B
30
S
11
G
11
Posts: 411
Reputation: 8,459

Post » Sun May 15, 2016 6:18 am

@MPPlantOfficial It's best if you put them under different groups (for performance reasons too). In other words, put all your main menu actions in one group and put all title actions in another group. Then disable groups depending on which is visible and clickable by the user. It's best practice to do this for everything else in your game if you are not using the actions at that specific moment. :)
Check out my games on Google Play:

BEAST ATTACK (960,000+ downloads!)

ZOMBIE BASH (Android) (Launched Feb 17)

ZOMBIE BASH (iOS) (Launched March 17)
B
50
S
15
G
2
Posts: 427
Reputation: 5,164

Post » Mon Aug 07, 2017 8:23 pm

Thanks... ;)
B
13
S
1
Posts: 62
Reputation: 717


Return to How do I....?

Who is online

Users browsing this forum: ivanski1983, KTML5 and 3 guests