• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Need suggestions for menu navigation

flyinian

Member
I am making an incremental game and I am going to have clickable buttons that will remain on screen through out the game. What would be an efficient way on doing this. I was originally going to just simply create the template for the room and duplicate that room but, then I thought how much of a pain it would be to make simple or massive edits to the buttons....in each room.

Also, I would like to get some ideas on how I could do the menu system within the game. I am currently planning on just having a room per button and have more buttons on those rooms.
 
T

Taddio

Guest
If it's an in-game menu, I wouldn't even go to a different room, just pause the game and draw what looks like a menu on top of your game, will save you some hassle eventually.
Also, you will want to look at parenting. All your buttons, altough they have different options, will have a lot of common behavior which they can all share via a parent object
 

flyinian

Member
If it's an in-game menu, I wouldn't even go to a different room, just pause the game and draw what looks like a menu on top of your game, will save you some hassle eventually.
Also, you will want to look at parenting. All your buttons, altough they have different options, will have a lot of common behavior which they can all share via a parent object
I'll be having features in my game that will rely on a continuous game flow(not pausing). It's not exactly an in game menu but, more of a page of a book and the buttons is the index of the said book. Each page is doing functions to add to a variable(money, population, etc.).

I guess the best example I can give is a text based game, idle game, and an incremental game.
 
If you know where all these buttons are going to be and they are always in the same spot, I'd just make a sort of control object that creates and places all the buttons in the room. That way yoy only need to put that control object in your rooms anywhere you like and it will handle the rest for you.

Edit: and if you need the buttons to do different things like using them to navigate rooms or whatever, you can just change that in the creation code of the control object and let it do it for you.
 
If you are using GMS 2, and your buttons function the same in every room, look into making a parent room with your menu buttons set up there.
 

flyinian

Member
If you know where all these buttons are going to be and they are always in the same spot, I'd just make a sort of control object that creates and places all the buttons in the room. That way yoy only need to put that control object in your rooms anywhere you like and it will handle the rest for you.

Edit: and if you need the buttons to do different things like using them to navigate rooms or whatever, you can just change that in the creation code of the control object and let it do it for you.
If you are using GMS 2, and your buttons function the same in every room, look into making a parent room with your menu buttons set up there.
This will help tremendously. I didn't know about parenting with rooms. The control object may come in handy.

One last thing, Should I be using code to place my sprites(buttons and such) or is it not a bad idea to manually place my sprites(buttons and such) in the room? I was having issues with sprites masks when resizing the application surface and one of my theories was that i'm not using code to place sprites.

Thank you.
 
I didn't know about parenting rooms either, but i don't have GMS2 yet. Sounds useful!

I personally prefer placing things by code but placing in the room editor is fine in my opinion usually.
 

Rob

Member
This will help tremendously. I didn't know about parenting with rooms. The control object may come in handy.

One last thing, Should I be using code to place my sprites(buttons and such) or is it not a bad idea to manually place my sprites(buttons and such) in the room? I was having issues with sprites masks when resizing the application surface and one of my theories was that i'm not using code to place sprites.

Thank you.
If you want these buttons throughout most of your game then I would use the GUI to draw the sprites. Use code to draw them. Use built in variables / variables of your own to work out where to place them. It can be a pain in the bum at first if you're not used to it but it will save you a lot of time in the long run (at least it did for me). I also didn't know anything about parenting rooms but I prefer to not switch rooms if I can avoid it. Just a personal preference.

In the same code that you're drawing the sprites you can also use that to detect for mouse clicks. This works with for loops too, so if you can draw everything using a for loop it will save you some lines of code.

One of my main reasons for using code to draw is that if you ever change the size of the rooms, the size of the buttons or anything like that, if you used built in functions like "sprite_width" etc to work out placement, the code should still work for any future changes.

Try and avoid "magic numbers".
 

flyinian

Member
I didn't know about parenting rooms either, but i don't have GMS2 yet. Sounds useful!

I personally prefer placing things by code but placing in the room editor is fine in my opinion usually.
If you want these buttons throughout most of your game then I would use the GUI to draw the sprites. Use code to draw them. Use built in variables / variables of your own to work out where to place them. It can be a pain in the bum at first if you're not used to it but it will save you a lot of time in the long run (at least it did for me). I also didn't know anything about parenting rooms but I prefer to not switch rooms if I can avoid it. Just a personal preference.

In the same code that you're drawing the sprites you can also use that to detect for mouse clicks. This works with for loops too, so if you can draw everything using a for loop it will save you some lines of code.

One of my main reasons for using code to draw is that if you ever change the size of the rooms, the size of the buttons or anything like that, if you used built in functions like "sprite_width" etc to work out placement, the code should still work for any future changes.

Try and avoid "magic numbers".

Are there any differences between GUIs and non GUIs? besides that GUIs are drawn above everything else and that they apparently display fonts cleaner.

Why do you prefer not switching rooms?

Why is placing things in the room editor usually fine.?

Curiosity killed the cat...

I was hoping I could keep this game rather simple in terms of coding. Now, I think that's not going to happen. Don't want to invest the time into a project and then realized that I can't continue without recreating a part of the game. However, this project that I am creating should be fairly easy to redesign since I am not going to have tons of assets that are hypersensitive(I hope and believe). Hope fully I can find some decent tutorials that hold your hand through for loops and such.

Thank you
 
T

Taddio

Guest
For my buttons, I almost always use a 2D array with all revelant information within it (x_pos, y_pos, pointers to what to do when clicked, hovered, arrow presses, etc.) and use a loop to draw them. A little bit more work in the beginning, but easier to tweak later on.
I don't really like placing stuff directly in the room editor, I dunno...
 

Rob

Member
Are there any differences between GUIs and non GUIs? besides that GUIs are drawn above everything else and that they apparently display fonts cleaner.

Why do you prefer not switching rooms?

Why is placing things in the room editor usually fine.?

Curiosity killed the cat...

I was hoping I could keep this game rather simple in terms of coding. Now, I think that's not going to happen. Don't want to invest the time into a project and then realized that I can't continue without recreating a part of the game. However, this project that I am creating should be fairly easy to redesign since I am not going to have tons of assets that are hypersensitive(I hope and believe). Hope fully I can find some decent tutorials that hold your hand through for loops and such.

Thank you
If I have to switch rooms, that means making everything persistent in the rooms I'm switching to and from. To me it's simpler and easier to have buttons drawn onto the Gui and use them that way.

If you place objects in a room as the GUI then you have to manually move all of them.

You can also come across problems when other people try to play your game (such as sprites being distorted - for more info, check out Pixelated Pope's video series on display ratio etc)

I make my GUI like Tadio usually and it's simple to code once you know what you're doing (like most things).

If you're already happy doing it 1 way then do that, though. It's better to finish a game than to stop because you tried to do something that was currently beyond you.
 
Top