Click event runs perpetually

devospicedevospice Member Posts: 16

I have a level select screen where the user selects which house they want to explore. When they click on the house an overlay appears that shows them the information about the house, such as the name of the child who lives there, their high score, best time, etc. Then they can either click "Go!" to enter the house, or click the "X" to close the overlay and select another.

The way this works is the overlay elements are off-screen. When the user selects a house the appropriate graphics are set and the entire thing is moved on-screen.

Everything was working fine until I got to the house in the upper right. Notice that the house sits directly below the close box for the overlay. When I tried to close the overlay that house's overlay was immediately opened with no way to close it because the house below the "X" was also getting the click event.

I couldn't figure out a way to stop a click event from propagating to elements below the top object (is there a way to do this?) so I created a new Game attribute called "Level Select Open." Quite simply, when a user clicks on a house that attribute is set to true. When the close box is hit it is set back to false. That should have fixed it, but it didn't.

What's happening now is whatever house I click on shows its overlay and as soon as I close it the overlay reopens. The reason for this, as far as I can tell, is that the click event only has to be triggered once and then everything inside that Rule will run perpetually.

How do I get the overlay code to stop running? I've tried various ways to implement this logic and nothing has worked. I even put a delay on the close box before resetting the game attribute in case things were just happening too fast but now the overlay just pauses for however long the delay is and then reopens. I'm kind of at a loss here.


  • Thunder_ChildThunder_Child Member Posts: 2,343

    Hmmm. May be tedious but maybe a set of true and false bolea s for those houses shoukd be that when your overlay is true make the house underneth false so it cant be clicked...and once Go has been clicked...make the house true again so it can be clicked? That was the first thing that popped into my head and I dont know if this woukd be the fix but woukd be my first thing to try.

  • devospicedevospice Member Posts: 16

    I'll give that a try. Thanks.

  • devospicedevospice Member Posts: 16

    OK, that didn't do it. That solved the problem of the house you clicked on getting a constant overlay, but now I'm back to "clicking on the close box opens the house under it."

    I think my only option at this point is to move the house. That sucks, though, because I've got 3 other screens like this one and I think it's going to be a problem on at least two of them.

    Thanks for your help.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,925

    Here's how I'd do it.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,859
  • colandercolander Member Posts: 1,610

    Have you tried using a timer? Using @Thunder_Child boolean suggestion add a timer in the X/Overlay actor and set it too change the boolean back to true after 0.5 seconds or whatever you want with run to completion checked. This could still cause a problem with a player who keeps their finger on the screen but that would be expected.

  • jorkosjorkos Member, PRO Posts: 353

    the best way to do this is just to add a rule to the house press that uses a boolean attribute:

    if pressed and boolean (onscreen) is false, then turn boolean.onscreen to true and perform the action

  • devospicedevospice Member Posts: 16

    That's what I did and it didn't work.

    Something is weird with this particular house, though. I managed to fix the problem by moving the house's button off-screne when the overlay appears and then moving it back on screen when it goes away.

    Then I implemented the code on the other three neighborhoods, two of which also had houses that overlapped the close button. Neither of those houses exhibited this problem. They worked fine right off the bat.

    I went back and looked at that troublesome house button. It has the same properties and scripts attached to it. So I don't know what is wrong but I managed to work around it.

    Thanks for your help.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,925

    Check to see if you've unlocked the house that isn't working. If you see a lock symbol when you double click on the actor in the scene, it's locked and using the same prototype rules. If you instead see "Revert to prototype" at the top of the rule list then that actor is unlocked and using different "instance" rules.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Sign In or Register to comment.