(Solved!) Title Screen & Menu Issues

Started by Vault15, Mon 15/10/2012 22:55:07

Previous topic - Next topic

Vault15

I have a rough shell of the game so far so I would like to add a title screen and menu when you first run the game.

My problem is that I literally have no idea where to start besides making a new Room (importing the Title screen image as the background) and attempting to disable the main game Guis so they are not visible.

I tried doing this but the Gui is still visible (bottom bar).

function room_AfterFadeIn()
{

  gIconbar.Visible = false;
}

Keep in mind that I have already made intros, mini cutscenes and understand basic scripting so I'm not completely oblivious to what's going on. What code do I need to disable the Guis and bring up a menu (start game, load, exit)?

Is there an example Gui I can import and modify as my title screen with buttons?

Any help is greatly appreciated. I really tried searching this topic so I'm sorry if it's been asked countless times. I can't seem to find anything that will take me through step 1. I'm still looking through help topics and will post updates if I figure out something.

Basically right now I have a town that you can roam around in and talk with npcs. After realizing that I wanted to make the intro/menu part before I continue, I decided to create another blank map, import a title screen image and attempt to make the Gui vanish. I set the player as default starting on the blank title screen map, but I can't figure out the best course of action for making title screen buttons and the (repeatedly mentioned) Gui not being in the way.


Steps I need to do:

1. Start up the game, Title screen loads the background with no bottom bar Gui blocking it.
2. Have the menu with a few buttons that I can control with keyboard arrow keys and press enter to select one
3. Once you select "new game" it will shift to another menu with a "create character" button (I'll add more options myself when I figure out the process)
4. A character creation screen where you can place stats, skills, age, name, etc.
5. Cutscene plays
6. Current map loads with the character stats implemented, including character graphic customization (very limited, will expand upon it)

I am very determined in continuing this project with pages upon pages of backstory/general ideas. I'm sure some of you have felt that inspiration where you work on a project night and day. I'm in charge of all coding since I have a background in it (hard to believe with how awful I am with this), soundtrack creation and sound effects. My friend at the Airforce Academy is especially good with artwork and storybuilding. I want to thank this forum for the people really out to help big projects get started. Rest assured your submitted responses will not be in vain and I'll eventually post a demo in a year or two so that you can see where your help went towards.

Crimson Wizard

#1
Quote from: Vault15 on Mon 15/10/2012 22:55:07
I have a rough shell of the game so far so I would like to add a title screen and menu when you first run the game.

My problem is that I literally have no idea where to start besides making a new Room (importing the Title screen image as the background) and attempting to disable the main game Guis so they are not visible.

Few tips:
1. Use Room number > 300. This room won't save it's state and everything will reset to starting position if player re-visits Main Menu.
2. Set Room property "ShowPlayerCharacter" to false (where applicable), since you probably won't want your player character appear on the screen with menu options (or would you? in which case don't :)).
3. You may make your main menu with Gui, indeed. But also you may make it literally of anything else: room objects, even characters.
Check this recently released game, for example, it has main menu made of 3 sheeps standing on hill. One sheep is "New game", another "Load" and third is "Quit":
http://www.adventuregamestudio.co.uk/forums/index.php?topic=46971.0
Actually I think most AGS games I saw used text drawn on room background or on objects to make main menu, rather than gui.

Vault15

#2
"
Few tips:
1. Use Room number > 300. This room won't save it's state and everything will reset to starting position if player re-visits Main Menu.
2. Set Room property "ShowPlayerCharacter" to false (where applicable), since you probably won't want your player character appear on the screen with menu options (or would you? in which case don't :)).

Actually I think most AGS games I saw used text drawn on room background or on objects to make main menu, rather than gui.
"

Hah, thanks I actually just changed ShowPlayerCharacter to False a bit ago. Alright so I can try objects on the room background and then from there see about using the keyboard to select them.

I still can't seem to get the Gui to go away. I went ahead and set the room number to 301 for the title screen as well.

Khris

Since, again, the code you posted should absolutely do the job, the only thing I can think of right now is that you either didn't link the function to the event and it isn't called at all or you're turning the GUI visible in some other part of the game.

Are you positive you're turning the right GUI invisible?

As for creating a menu, it's as simple as creating a GUI (Visibility: Normal, initially on) and putting buttons on it that do stuff like "gMenu.Visible = false; player.ChangeRoom(2);" for "New Game". The GUI's background could be transparent so the menu graphic is room background + GUI buttons.
Alternatively, you can use hotspots on the background and their "any click on" event.

The best way to go about this depends on the specifics of the desired result. If you're using a GUI you can add mouseover and pressed graphics to GUI buttons to add some eye candy.
If you want to add keyboard controls to the menu, just put an on_key_press function in the menu room. Copy the one in GlobalScript.asc and remove all the key handling, then add blocks for eKeyEnter, eKeyArrowUp and eKeyArrowDown.
Say you want an arrow sprite that's pointing to the current option. You could use a room object, an empty GUI (with its background graphic set to the arrow sprite) or an additional GUIControl.
Then use something like this:
Code: ags
int option = 0;  // new game is default

void on_key_press(eKeyCode k) {
  // menu options New Game, Load, Quit. Arrow sprite positions: y = 100, 120, 140
  if (k == eKeyEnter) {
    if (option == 0) {
      gMenu.Visible = false;
      player.ChangeRoom(2);
    }
    if (option == 1) show_restore_game_dialog();
    if (option == 2) QuitGame(1); // user has to confirm
  }
  go = 0;
  if (k == eKeyUpArrow) go = -1;
  if (k == eKeyDownArrow) go = 1;
  if (go == 0) return; // don't handle other keypresses

  option = (option + go + 3)%3 ;  // change option, wrap around
  oArrow.Y = 100 + option*20;   // move arrow
}

Vault15

#4
Update: I made the bottom bar Gui (gIconbar) initially off instead(in gui settings). I don't know why I can't just disable it in the map scripting, but oh well.

For the town1 map script I added:
gIconbar.Visible = true;
gTitleScreen.Visible = false;

For the Title Screen map (301) I added:
gIconbar.Visible = false;
gStatusline.Visible = false;

and now I'm able to switch from the title screen to first map just by changing who the default character is (player 1 or TitleScreen character) since they, of course, have different starting maps. The title screen character is just a box that is invisible. So that's a baby step and thank you for the code :). I think I will choose the Gui method since you can do the nice press-down effect when clicking a button. I do want it to look professional.

amateurhour

I just made a title screen that does the job pretty well using a static image background with three hotspots for new game, load, and quit, and here's the code I used, if it helps.

Code: AGS
// room script file

function room_AfterFadeIn()
{
  Mouse.Visible = true;
  Mouse.Mode = eModePointer;
}

function hnewgame_AnyClick()
{
  player.ChangeRoom(2);
}

function hloadgame_AnyClick()
{
  gRestoreGame.Visible = true;
}

function hquitgame_AnyClick()
{
  QuitGame(1);
}


Note: The mouse visible was activated because the mouse, status bar, and icon bar are turned off during my opening credits cutscene (room) and I don't turn them back on until later, except for the mouse temporarily so that I can navigate the title screen itself.

It was literally that simple, unless I've done it wrong, but it works.     
Co-Founder of Pink Pineapple Ink Pink Pineapple Ink
Creator of the online comic Trouble Ticket Trouble Ticket

Vault15

Quote from: amateurhour on Tue 16/10/2012 01:33:15

Note: The mouse visible was activated because the mouse, status bar, and icon bar are turned off during my opening credits cutscene (room) and I don't turn them back on until later, except for the mouse temporarily so that I can navigate the title screen itself.

It was literally that simple, unless I've done it wrong, but it works.     

I just made a title screen that does the job pretty well using a static image background with three hotspots for new game, load, and quit, and here's the code I used, if it helps.       

Thanks! I went ahead with the Gui option but a lot of the coding will be good to have since I have to script the buttons the same way. I was able to make a title screen and now it's just a matter of linking everything the right way. Really appreciate the help  :)

SMF spam blocked by CleanTalk