text boxes probs

Started by Terrorcell, Fri 03/08/2007 21:31:50

Previous topic - Next topic

Terrorcell

hi, say I want one text box to appear if I type the right thing into the first text box. So I have one text box to begin with. if I type the right number into this text box, then right below it, another appears. IU dont know whether this is in the help or not but how do I do this?

Recluse

It sounds like it would be easiest to do this is with a GUI. If you have a background you would make 2 different background sprites for your GUI... 1) with only the first text box showing, and 2) with both text boxes showing just like you want them to appear.

Set up your GUI so that you have both text boxes where you want them, and set one to start out invisible. Once the number typed into the first text box has been validated as correct, set the second text box to be visible. If you have a background you will need to change the background image of the GUI to the second background as well.

If there's a better way to do this, someone please say so, because this is the way I handle such things in my game currently.
All your verbcoin are belong to us.

Ashen

Which bit are you asking for help with?

Anyway, Recluse pretty much has it. You'll probably want this command, if you haven't already found it: TextBox.Enabled (so only the TextBox you want to accept input is working at the time). The rest should be basic variable handling (check the TextBox contents against what it should be and react accordingly) but if you have any specific problems, post them.
I know what you're thinking ... Don't think that.

Terrorcell

I was actually expecting something in the scripting sense. If anyone has any clue to my prob then please reply.

Ashen

Again, which bit do you need help with? It's not actually that hard, but knowing where you've got to by yourself would be a start.

Basically:
* Make a GUI. Put two TextBoxes on it, maybe a Button depending on how you want to trigger things, and any other Controls you need. Name them.
* Before you use the GUI for the first time, use TextBox.Enabled to disable the second TextBox.
* In the Control function for the first TextBox (or the Button, if you prefer) add some code to check the contents of the first box, and react as needed, e.g.:
Code: ags

  if (txtFirst.Text == "3") { 
    // the right response, disable the first TextBox and enable the second
    Display("Well done.");
    txtFirst.Enabled = false;
    txtSecond.Enabled = true;
  }
  else Display ("Try Again.");
}

(see? All pretty basic code really.)
  If you have different background images for each box, as Recluse suggested, use GUI.BackgroundGraphic to change between them.
* Repeat as needed.
I know what you're thinking ... Don't think that.

SMF spam blocked by CleanTalk