GUI Toggle Button [Solved]

Started by KamikazeHighland, Tue 05/10/2010 02:50:23

Previous topic - Next topic

KamikazeHighland

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.

Khris

You don't need a variable, just use

Code: ags
  GuiName.Visible = !GuiName.Visible;


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

Code: ags
  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).

tzachs

And also you should have written if (var1 == 0) and not if (var1 = 0).

KamikazeHighland

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

SMF spam blocked by CleanTalk