Room1 (mainmenu) related topics

Started by chip, Tue 23/02/2021 16:17:31

Previous topic - Next topic

chip

Im working on a main menu, most of the functional side is done I believe

There are clickable areas for start, load, and quit in form of hotspots, they work and do what I want so far,
is this a good way to do this?
One thing I dont like with this is when I hover mouse over the hotspot areas it renders the text "Walk to Hotspot 1".
Is it possible to hide these texts only for this specific room?




Matti

#1
I guess you're using the Tumbleweed template? I'm not sure how it works so I can't help with disabling it for a specific room.

But when creating a menu you would usually create a GUI for that. This has many advantages, as you can make it visible/invisible, rearrange it, and "start", "load" etc would be buttons that can also change sprites when you click or hover over it.

RyanIsntAlive

Yeah in full agreement with Matti on this.
Because it's set up like a room, it will behave like any other, so the game will expect characters to possibly be walking around and interacting in it.
Thankfully if your room is mostly set up, the code can easily be copied over, and creating a GUI for a main menu should be pretty easy. This should be a little minor change.

At the top of your global script, you should find a function called game_start(), This is where you'll want to set up your menu. Just go to the right hand menu and right click gui, then create a new gui (I'll use gMenu for example), you can then add buttons and sliders and whatever your heart desires, you can change the background image to whatever you want with the "BackgroundImage" in the properties. If you want it to fill the screen, set the size to whatever your game's resolution is. You can then place buttons and change their sprite, and have those buttons for save, start, quit.

Going back to that game_start() function, You'll want to make the code look something like this.

Code: ags

function game_start()
{
   gMenu.Centre();
   gMenu.Visible = true;
}


That's it, that's all you'll need.

For buttons like Quit, save, etc, Just move the existing code,

Code: ags

function Save_OnClick(GUIControl *control, MouseButton button)
{
  SaveGameDialog();
}

function Load_OnClick(GUIControl *control, MouseButton button)
{
  RestoreGameDialog();
}


That's all you'll need for save and load, quit game, I'll let you figure out, that's the fun of coding.

Starting your game you can do with gMenu.Visable = false; that'll just hide the menu, and let you play your game.
If you want to get technical, you can have things like PauseGame(); but that's only if you have things auto running when the game starts.

That's all your basics of menu GUI, I'm taking this from my code, which works fine, although I'm not running Thimbleweed so you may have to modify it a little, I realise it may not be too clean, but as I said you can modify to your preference, If you need me to explain any of it, I'll gladly break it down a little more, but just experiment.

That start button is a really nice asset btw, you're doing great.
The guy with the CRT Television Project!

chip

Thank you for your help, very nice :smiley:

As both of you suggested I have recreated the menu with the gui now, and its working!

There were some minor problems with the wrong (default?) options dialog popping up with your code, I guess its related to the tumbleweed theme, but I could figure it out. Thanks again for your input and pointing me in the right direction.

RyanIsntAlive

Great to hear! Can't wait to see what you make!
I did think tumbleweed might have some different lines of code, but I'm glad you got it working! Good luck!
The guy with the CRT Television Project!

SMF spam blocked by CleanTalk