Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Gribbler on Thu 11/10/2012 13:20:26

Title: Creating Main Title screen
Post by: Gribbler on Thu 11/10/2012 13:20:26
Hello!

I want to make a title screen for my game. I have all game rooms already created. I added additional room - number 1. It is a simple png file with a title and three signs below it: PLAY, LOAD and QUIT. I made hotspots out of them. I hid the character in this room and my game has a inventory panel at the bottom. Here's code for the room:

Code (AGS) Select

function hQUIT_AnyClick()
{
QuitGame(1);
}

function hLOAD_AnyClick()
{
//show_restore_game_dialog();
}

function room_Load()
{
gInventory.Visible = false;
gIconbar.Visible = false;
}

function hPLAY_AnyClick()
{
player.ChangeRoom(3, 121, 120);
player.FaceLocation(283,  92);
gInventory.Visible = true;
gIconbar.Visible = true;
}


I have two problems here. First, LOAD hotspot. I entered the code from the button found in the default iconbar but I keep getting message: undefined token show_restore_game_dialog. I don't know why. If I keep iconbar visible, LOAD button in it works fine, and it has the same code.
Second problem is - while on this main title screen I still have the option to cycle through cursor modes: see, talk, interact etc. but I want it to be just cursor arrow, exactly as you have when you move cursor over iconbar when visible.

What do I do? Beside RTFM, which I already did:)

Any help would be greatly appreciated.
Title: Re: Creating Main Title screen
Post by: OG on Thu 11/10/2012 13:42:28
First problem:

Throw this in the load hotspot AnyClick -

Code (AGS) Select
lstRestoreGamesList.FillSaveGameList();
gRestoreGame.Visible = true;


Second problem:

Throw this in the room's room_load -

Code (AGS) Select
mouse.Mode = eModePointer;
Title: Re: Creating Main Title screen
Post by: geork on Thu 11/10/2012 13:44:09
Hello Gribbler!

For the first problem:
show_restore_game_dialog() is not a universal function and only really works in GlobalScript.asc first you'll need to export it. in GlobalScript.ash write
Code (AGS) Select
import function show_restore_game_dialog();
and the LOAD hotspot should work fine!

There are two ways of combating the second problem:

The first is to simply deactivate all the Mouse modes apart from the pointer mode, and set it to that. so maybe in the room script something along the lines of:
Code (AGS) Select
function room_Load()
{
gInventory.Visible = false;
gIconbar.Visible = false;
Mouse.Mode = eModePointer;
Mouse.DisableMode(eModeInteract);
Mouse.DisableMode(eModeLookat);
//etc etc
}


The second way I preffer more as it's a little more elegant: You could merely check in the function that handles the way you change modes (I assume it's right click, so the function would be on_mouse_click() in GlobalScript.asc) to see whether the player is in Room 1, and block the appropriate expression accordingly. It'll look something like:
Code (AGS) Select
function on_mouse_click(MouseButton button) {
//some stuff including an if statement if I remember right...
  else if (button == eMouseRight && player.Room != 1){ //checks whether the player is in room 1, and if so will stop the expression from executing
    mouse.SelectNextMode();
  }
}

which should stop your mouse mode from changing until you leave the menu

Hope that helps :)

EDIT: Onker got there before me ;)
  Although merely setting the mouse mode to pointer doesn't solve the issue (for the second bit), as the modes can still rotate.
Title: Re: Creating Main Title screen
Post by: OG on Thu 11/10/2012 13:56:34
True. haha. Geork is right with:

Code (AGS) Select
Mouse.Mode = eModePointer;
Mouse.DisableMode(eModeInteract);
Mouse.DisableMode(eModeLookat);
//etc etc


Not sure how that one slipped the ol' mind.
Title: Re: Creating Main Title screen
Post by: Gribbler on Thu 11/10/2012 13:58:54
Thank you so much guys! You're unbelievable here:)
Title: Re: Creating Main Title screen
Post by: Khris on Thu 11/10/2012 13:59:12
As a general note, functions don't need to be exported, just imported (geork's code is fine though). Only global variables/pointers need to be exported.

Regarding the mouse mode issue: Just add this to your room script to disable everything but left-clicks:
Code (ags) Select
void on_mouse_click(MouseButton button) {
  if (button != eMouseLeft) ClaimEvent();
}

This will prevent the global on_mouse_click from being executed.

Set the mode to pointer like Onker suggested and don't forget to set it back to eModeWalk in the first room's room_Load().