Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: KamikazeHighland on Tue 05/10/2010 02:50:23

Title: GUI Toggle Button [Solved]
Post by: KamikazeHighland on Tue 05/10/2010 02:50:23
Mostly solved.  I just need to make an on / off button.  :-\

0 to 1 and back to 0 each time the button is pressed.  I tried [if (var1 = 0) var1 = 1;] and vice versa but nothing happened.
Title: Re: GUI Toggle Button
Post by: Khris on Tue 05/10/2010 11:05:44
You don't need a variable, just use

  GuiName.Visible = !GuiName.Visible;

To switch a variable from 0 to 1 and back, use

  var1 = 1 - var1;

The reason why this didn't work for you depends on where you put that code and where you defined the variable (and the code that actually switches the GUI's visibility).
Title: Re: GUI Toggle Button
Post by: tzachs on Tue 05/10/2010 14:45:49
And also you should have written if (var1 == 0) and not if (var1 = 0).
Title: Re: GUI Toggle Button
Post by: KamikazeHighland on Tue 05/10/2010 15:58:35
Quote from: tzachs on Tue 05/10/2010 14:45:49
And also you should have written if (var1 == 0) and not if (var1 = 0).

I actually did use two ==, but thanks.  Anyway, Khris your code worked perfectly!  That's a brain teaser equation!  And a lot simpler than and if/then statement. 8)

Thanks!  ;D