keskiviikko 24. elokuuta 2016

Unity platformer - menu

NAV15AP & NAV16AP

1. jakso lukuvuonna 2016-2017

In this assignment you are going to use NGUI to make your game menu. NGUI is a very powerful tool for creating graphical user interfaces. You can use it for inventories, crafting systems, health bars, menus and many more applications.

Start by creating new scene for your menu. New scene can be created from the file tab in the top tool bar. 

Next you need to create new label for your game title. Select NGUI -> create -> label. The system makes UI root object automatically. This is the base for all the GUI objects you need in your game. You need to select the UI root to change settings in it. Select proper width and height for your project so that all the objects in the UI root will scale according to your settings.



Then you’re going to make changes to the label created before. Change the size of widget so that you can fit larger font in it. Change the font size too so that the title of the game is clear and attracts most of the attention. You can also select color and gradient for the label from the UI label menu.


Create two more labels. One named new game/start and the other one named exit. We want to be able to start a new game by selecting new game which will take us to the first playable level of the game. We also need exit so that the player can exit the game without pressing ctrl+alt+del.


Then you’ll need an empty game object to create controls for the menu. This time you’re going to use arrow keys to navigate the menu. Add FSM in the empty game object. There will be 4 states in this FSM. In the first state you need two get key down actions. First is for the arrow key and second is for enter. With the arrow key you can navigate to the next state that will activate the exit label. The enter key will confirm that the player wants to start a new game and it transitions to the state where a new level is loaded.


The next state will be like the first state. This time you need to make transition back when you press arrow key up. Pressing enter will take you to another state that will quit the application. You’ll also want to use some indicator that the exit game label is selected. Easier way to do this is to use different color. You need to set property for the UI label to change its color and second set property to change the new game label color back to the color that tells the player new game is not active.


Create two more states. One is for quitting the game and in that one you’ll need the quit application action. In the other state select load level action. Write the level name you want to load in that action.




Lastly you need to make sure that both levels you have created are in the build. When the game is built it makes .exe file from the scenes you have added to the build. If you have no scenes in there, then it won’t be able to build anything. It’s important to have the menu scene at the top of the list because it will be the first scene the game loads. Build settings can be accessed from the top tool bar under file tab.

Ei kommentteja:

Lähetä kommentti