Toggle Something On/Off

Non-platform specific questions.

Toggle Something On/Off

Postby Super Pieman » Sun Nov 04, 2007 3:12 pm

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
Current Projects:
*Lonely (2%)
**LinkSys (1%)

*To be made in GE, then ported to DS.
**To be made for the DS.
User avatar
Super Pieman
 
Posts: 57
Joined: Sat Nov 03, 2007 3:27 pm
Location: Manotick (Ontario, Canada)
Score: 2 Give a positive score

Re: Toggle Something On/Off

Postby makslane » Sun Nov 04, 2007 6:19 pm

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.
Game Editor is an open source game creator software that's wants to pay it's developers to keep evolving.
If you like Game Editor, make a review!
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Re: Toggle Something On/Off

Postby Super Pieman » Sun Nov 04, 2007 10:41 pm

but what if i want to turn it off using the "i" key also.
Current Projects:
*Lonely (2%)
**LinkSys (1%)

*To be made in GE, then ported to DS.
**To be made for the DS.
User avatar
Super Pieman
 
Posts: 57
Joined: Sat Nov 03, 2007 3:27 pm
Location: Manotick (Ontario, Canada)
Score: 2 Give a positive score

Re: Toggle Something On/Off

Postby Fuzzy » Sun Nov 04, 2007 11:15 pm

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?
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron