So I’m trying to make a clickable “help” button that reveals some text. Originally the opacity variable for the text is set to 0, and set to update every frame. The following code is used in the “begin routine” tab to set the opacity of the help text to 0 in every repeat.
opacity1 = 0
In the “each frame” tab the following code is used to detect a click on the help icon, changing the opacity of the text, revealing it.
if mouse.isPressedIn(help_icon) and clicked == 0:
print("button was pressed")
opacity1 = 1
clicked = 1
The “clicked” variable is there to ensure the button can only be pressed once per repeat of the routine and is set to 0 in the “begin routine” tab as well. The “print” function is there for debugging purposes to check if the code detects that the button was pressed. It always executes when I run the code and click the button, confirming that it detects the click.
My problem is that the help text is always revealed, it is never hidden. From when the routine begins, regardless of whether the help icon was pressed or not, it is always visible. How can I fix this?