Page 1 of 1
Toggle Something On/Off
Posted:
Sun Nov 04, 2007 3:12 pm
by Super Pieman
Quick question, I have a stat bar at the top of my game screen, but I only want it visible if you press the "i" button. How do I get this to happen
Re: Toggle Something On/Off
Posted:
Sun Nov 04, 2007 6:19 pm
by makslane
In the 'Create Actor' event of the bar, use the action 'Visibility State' to make the actor invisible (Event Actor, Disable).
After this, use the 'Key Down' event to make the actor visible again when the user press the 'i' key.
Re: Toggle Something On/Off
Posted:
Sun Nov 04, 2007 10:41 pm
by Super Pieman
but what if i want to turn it off using the "i" key also.
Re: Toggle Something On/Off
Posted:
Sun Nov 04, 2007 11:15 pm
by Fuzzy
in your global code, type this:
#define TRUE 1
#define FALSE !TRUE
create a variable for your player, ShowStat
make it an integer
if only the player actor needs it, make it global, to save memory.
select player...create actor.... script.... put this line:
ShowStat = FALSE;
now, in the key down event for the i key, you put the first line like this:
ShowStat = !ShowStat;
transparency = !transparency;
Thats it. It will flip the state whenever you press i. Its considered proper programming to use all capital letters with #define, and it never uses ; at the end of a #define line.
Pretty simple, huh?