Hi, I'm trying to make a inventory for my game, there have 4 bags each bag has 20 slot inside.
now I need a array called bagList() that allow to store slotList1(), slotList2, slotList3(), slotList4(). and each slotList array has different item inside.
I have been created them like this:
static var bagList= new Array();
static var slotList1=new Array();
static var slotList2=new Array();
static var slotList3=new Array();
static var slotList4=new Array();
//add bags
bagList[0]=(slotList1);
bagList[1]=(slotList2);
bagList[2]=(slotList3);
bagList[3]=(slotList4);
//add items
slotList1[2]=("Assets/Items/testing");
slotList1[15]=("Assets/Items/testing");
slotList3[3]=("Assets/Items/testing");
slotList2[8]=("Assets/Items/testing");
slotList4[11]=("Assets/Items/testing");
that's a good start everything is work.
but I got many questions when I'm trying to processing with my arrays.
**1.how to get the slotList1.length by through bagList? (eg:bagList[1].length)**
**2.how to get the first item that inside slotList1 by through bagList? (eg:bagList[1][0])**
**3.how to add item to slotList1 by through bagList? (eg:bagList[1][0][2]="apple")**
I know how to get/add items for single array (eg:slotList1[2]="apple")
but in my game situation that must take bagList first then slotList.
can anyone help me please?
If you can bring some example that would be perfect! (JavaScript please)
↧