Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Pixelton on Sat 03/04/2010 12:46:59

Title: Front end GUI
Post by: Pixelton on Sat 03/04/2010 12:46:59
I'm not so sharp when it comes to AGS script and while I am making steady progress theres still alot of black holes. At the moment I'm trying to create a main menu gui (art wise this has been done) I'm just fuzzy on the code behind the buttons.

I have a simple "Start", "Load" and "Quit" button on my main menu. The Start just needs to go to a room, while load brings up the usual load dialogue box....is obviously quite self explanatory.

For the Start button I tried using a simple 'character.ChangeRoom(2);' but that doesnt seem to do anything so I'm abit at a loss at even that simple of a task. Any help is much appreciated in getting the GUI working.

MB.
Title: Re: Front end GUI
Post by: tzachs on Sat 03/04/2010 13:03:41
Have you linked the button click event to the function?
You have to do it in the designer of the gui, select the button, and then press the lighting bolt in the right bottom area, you will see the 'click' event with a '...' button, you have to click it, it will generate the function for you and you have to put the character.ChangeRoom in there.

If you did it and it doesn't work, the only other thing I can think of is that maybe the character that you changed the room for isn't the player character.
Title: Re: Front end GUI
Post by: Pixelton on Sat 03/04/2010 13:08:16
oh yeah I have done that...its just not playing ball. I'm still messing about to to see if I can get it working but no luck yet.
Title: Re: Front end GUI
Post by: Danman on Sat 03/04/2010 13:11:05
The way I did this. ( I don't know it is buggy or anything but I doubt it.)

I made an object that is the button. Linked it to a Any click. Then player.changeroom function.  
It works with me.  

But sounds like what tzachs said.
Title: Re: Front end GUI
Post by: Pixelton on Sat 03/04/2010 13:15:21
ah so you made your main menu GUI from not really using the GUI functions in AGS? I only have one character and he is the playable.

----
Actually I cant seem to get any of the buttons to work...I set my quit button to:   QuitGame(1);
I expected my game to close and it didn't.... confused. I might just have to build my menu from object sprites as Danman suggested - I'm not too comfortable with GUIs - the reason for trying to make a main menu...I thought....I have to dip my toe at some point into GUI scripting.

(http://blacktreeuk.net/johnny_r/main_menu.jpg)
Title: Re: Front end GUI
Post by: tzachs on Sat 03/04/2010 13:26:07
Try to put a breakpoint in the character.ChangeRoom line (right click the line in the code editor and click on toggle breakpoint). Then run the game and press on the button, see if it stops on that line. This will let you know if the problem is with the linking of the event or something else.

There's no need to use Danman's method, the GUI should do just fine...

Also try to look at densimng tutorials about guis, maybe it could also help you:
http://www.youtube.com/user/densming#p/c/21DB402CB4DAEAEF/37/7-GeX7E0Mss (http://www.youtube.com/user/densming#p/c/21DB402CB4DAEAEF/37/7-GeX7E0Mss)
http://www.youtube.com/user/densming#p/c/21DB402CB4DAEAEF/38/801LgME8MJ0 (http://www.youtube.com/user/densming#p/c/21DB402CB4DAEAEF/38/801LgME8MJ0)
Title: Re: Front end GUI
Post by: Pixelton on Sat 03/04/2010 13:30:32
Yeah the video tutorials are great, I;ve already watched through them about 4 times now :) great learning material.

I put a breakpoint in my change room function and on clicking the button I dont get any kind of feedback so it looks like its just not linked (this is also the same for the Quit button).
Title: Re: Front end GUI
Post by: tzachs on Sat 03/04/2010 13:41:05
When you're in the designer and press on the lighting bolt for your button, is the name of the function written next to the click identical to one of your function with the changeroom? Is the function located in the global script?
Try also to delete the function name and pressing the '...' again and placing the code there again...
If that still doesn't help, maybe you can upload a sample project with the problm, and I'll try to look at it.
Title: Re: Front end GUI
Post by: Pixelton on Sat 03/04/2010 13:51:34
Yes I have checked over my functions and it all seems correct...bare in mind my script knowledge is pretty bad still so it could well be wrong in a number of areas.

Here is a link to the project file.

www.blacktreeuk.net/download/Visitors.zip

Thanks for this Tzacks I'm sure you have better things to do with your time! haha.

Mark.
Title: Re: Front end GUI
Post by: Khris on Sat 03/04/2010 13:59:13
Set gMain's Clickable property to true :)
Title: Re: Front end GUI
Post by: Pixelton on Sat 03/04/2010 14:04:08
oh boy...that simple :(

I have noticed a strange behaviour with the load save game window whe nits called using my gMain GUI. When the window is displayed it's buttons (cancel & Restore) dont seem to be working. Am I going about calling the load screen in the correct way or is there another kind of command I need to be using instead of   show_restore_game_dialog();

Cheers Guys your all stars!
Title: Re: Front end GUI
Post by: Matti on Sat 03/04/2010 14:12:09
You can't click the buttons because the load GUI is behind the gmain GUI. Set the loading GUI's zOrder to something higher than 1.
Title: Re: Front end GUI
Post by: Pixelton on Sat 03/04/2010 14:24:51
Ah great just saw the draw order property, thanks for that...you guys have really helped me out...like a crash course in AGS GUIs! hehe

Cheers Guys.