Game Development Reference
In-Depth Information
Engage Thrusters
We will start with adding the parameters, which we will use to store the data in our
inventory page:
1. Open Menu.js , and add the following code to it; first the parameters:
//Item Tab
private var r_itemsBox : Rect = new Rect (237, 67, 360, 247);
private var r_tipBox : Rect = new Rect (237, 330, 360, 107);
private var r_itemsButton : Rect = new Rect (257, 87, 340, 227);
private var r_tipButton : Rect = new Rect (257, 350, 340, 87);
private var r_verScroll : Rect = new Rect (600, 87, 20, 227);
private var f_scrollPos : float = 1.0;
private var scrollPosition : Vector2 = Vector2.zero;
private var scrollPosition2 : Vector2 = Vector2.zero;
private var in_toolItems : int = 0;
2. Then, go to the Start() funcion and add the following code at the end:
if (a_items.Length > 0) {
a_items[0].setUpItemName();
currentItem = a_items[0];
}
3. Next, go to DoMyWindow (windowID : int) and uncomment the highlighted
line as follows:
case 1 : //Items
//Create an item page
ItemWindow();
break;
4. Then, we need to create an ItemWindow() funcion to show this inventory page.
Type this following funcion in Menu.js :
private function ItemWindow() : void {
var in_items : int = 8;
//Create Item Information box
GUI.Box (r_itemsBox, "");
GUI.Box (r_tipBox, "");
scrollPosition = GUI.BeginScrollView (new Rect (257, 87, 320,
200), scrollPosition, new Rect (0, 0, 280, 40*in_items));
// We just add a single label to go inside the scroll view.
Note how the
// scrollbars will work correctly with wordwrap.
var itemsContent : GUIContent[] = new GUIContent[in_items];
 
Search WWH ::




Custom Search