how do you create a "toggle" button

Talk about making games.

how do you create a "toggle" button

Postby stevenp » Fri Jan 04, 2008 1:14 pm

how do you create a "toggle" button? like press the button once it goes to a menu, press the button again, it exits the menu?

i have the menu already but the way im using it is, key down ( go to menu) key up go back to normal position screen, and that gets annoying
User avatar
stevenp
 
Posts: 403
Joined: Sat Dec 22, 2007 12:49 pm
Location: canada, ontario
Score: 16 Give a positive score

Re: how do you create a "toggle" button

Postby Bee-Ant » Fri Jan 04, 2008 1:26 pm

Before i explain it, do you know how to make timers well???
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: how do you create a "toggle" button

Postby stevenp » Fri Jan 04, 2008 1:44 pm

ya my game is 80% collision events and timers lol
User avatar
stevenp
 
Posts: 403
Joined: Sat Dec 22, 2007 12:49 pm
Location: canada, ontario
Score: 16 Give a positive score

Re: how do you create a "toggle" button

Postby Bee-Ant » Fri Jan 04, 2008 1:56 pm

OK...
Well, first make a variable called "menu",integer
Do you mean do 2 things or more in 1 button right?
Keydown>Button>
Code: Select all
if(menu==0)
{
    //go to menu2 from menu1
    CreateTimer("Menu2Set", 50 ms);
}

Timer>Menu2Set>
Code: Select all
menu=1;

Keydown>Button>
Code: Select all
if(menu==1)
{
    //back to menu1
    CreateTimer("Menu1Set", 50 ms);
}

Timer>Menu1Set>
Code: Select all
menu=0;
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: how do you create a "toggle" button

Postby stevenp » Sat Jan 05, 2008 12:44 am

i meant going from the game screen, to the menu, and back, all with only 1 button, like a toggle, on / off , but il try that and see if it works
User avatar
stevenp
 
Posts: 403
Joined: Sat Dec 22, 2007 12:49 pm
Location: canada, ontario
Score: 16 Give a positive score

Re: how do you create a "toggle" button

Postby Game A Gogo » Sat Jan 05, 2008 1:12 am

depends how your translation is controlled, if it's controlled by a variable, use this:
Code: Select all
Var=!Var;
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Re: how do you create a "toggle" button

Postby Bee-Ant » Sat Jan 05, 2008 8:58 am

mojo domo wrote:i meant going from the game screen, to the menu, and back, all with only 1 button, like a toggle, on / off , but il try that and see if it works

My code would be like that...
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: how do you create a "toggle" button

Postby pdude1 » Sun Jul 13, 2008 10:15 pm

do you know how to toggle stuff like weopons so i can make my guy switch from a machine gun to shotgun and stuff like that?
does anyone know a good signiture
User avatar
pdude1
 
Posts: 10
Joined: Sun Jun 29, 2008 8:30 pm
Score: 0 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron