How do I disable TOUCH for specific objects?

0 favourites
  • 7 posts
From the Asset Store
Welcome! I-Spy (Hidden objects) is an educational puzzle that is more than just seek-and-find activities.
  • 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!

  • 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.

  • But yes, destroying all the unneeded buttons work too.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • How about:

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

  • [quote:i1mreoa6]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.

  • 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.

  • Thanks...

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)