I have to write an XNA game for a project in my college program. I’m making a turn-based RPG in the vein of the Gameboy Pokemon games. I’d like to align the menu options with a container at the bottom of the screen, with never more than 4 options. This should give you a rough idea about how I want the combat screen to look:
I currently have a menu system that aligns all the menu items with the center of the screen, meaning menus end up looking like this:
Start Game
Options
Quit
but in the center of the screen.
What is the best way to position the menu items in a similar fashion to the image above? Should I hardcode in the positions for the menu items, should I try and make some kind of class to act as the container for these items and have their position be relative to the size and position of the container, or use some other method?
If you don’t want to hardcode the positions it could get pretty complex, depending on how much flexibility you want.
I would create a container class which is part of a tree structure, (see scene graph), with a parent container and a list of child containers. That is the most common way of handling relative positioning. Here a quick example:
If you need even more flexibilty you could create a floated layout, where the elements are positioned dynamically depending on their size.