Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualJETerán

Posted 22 August 2012 - 04:47 PM

Hey guys, it’s good to be around here.

I’m facing a little problem that has to be with arrays in the game. This is what I want to do and how I plan to do it, and my results. I want to be as clear as possible, really hate when people just say “help” and paste their code :S

I’m trying to make a very simple inventory system. Keep in mind that I already check some of them on the Internet, but it really bothers me to just “copy-paste” code that it’s not mine. So I’m using them for learning purpose. I want to go step by step, so for now I will concentrate only in the inventory (not the buying system)

Ok now, I have 2 scenes in the game. The briefing scene where you can buy goods and save them in your inventory, and the other one is the game scene where you use the objects you bought.

In the briefing scene, I want to save the objects I bought in my inventory, for this I think is best use a fixed array. That array has always 4 slots.

What I want to do is save that array and passed it to the game scene and put them in another array.

With this (I hope) clear explanation, I have some questions:
- Can I use only one array for that inventory? So I save the objects in the briefing scene and call it in the game scene?
- With a future buy system, (that I think it will be another array) what can be the best method to pass them to the inventory array? With just push (or slice?)?


Now, about the game scene:
With the objects in the inventory, I want to be able to drag them to objects in the game scene (table, computer, etc) and, if the inventory objects hitTest the table AND the character, drop it. I’m working this in a different file than the briefing scene BTW.

Now I have some Qs:
- I have 3 objects inside an array called invObjects. To put them in the scene, I used a simple FOR that tells the program to put them in X order. They do. Just after this, I added an event listener to know where the invObject is clicked. In that function, I did: invObjects[i].startDrag() but says that the object is null, why?
- When that object is used correctly in the scene, I want it to pop(). If I pop it, those the other objects stay where they are? Pop it is the best method to be used?


I’ll appreciate any suggestion you give me. Anyway I’m working on all this.

Thanks so much guys for your help !!

#1JETerán

Posted 22 August 2012 - 03:50 PM

Hey guys, it’s good to be around here.

I’m facing a little problem that has to be with arrays in the game. This is what I want to do and how I plan to do it, and my results. I want to be as clear as possible, really hate when people just say “help” and paste their code :S

I’m trying to make a very simple inventory system. Keep in mind that I already check some of them on the Internet, but it really bothers me to just “copy-paste” code that it’s not mine. So I’m using them for learning purpose. I want to go step by step, so for now I will concentrate only in the inventory (not the buying system)

Ok now, I have 2 scenes in the game. The briefing scene where you can buy goods and save them in your inventory, and the other one is the game scene where you use the objects you bought.

In the briefing scene, I want to save the objects I bought in my inventory, for this I think is best use a fixed array. That array has always 4 slots.

What I want to do is save that array and passed it to the game scene and put them in another array.

With this (I hope) clear explanation, I have some questions:
- Can I use only one array for that inventory? So I save the objects in the briefing scene and call it in the game scene?
- With a future buy system, (that I think it will be another array) what can be the best method to pass them to the inventory array? With just push?

Now, about the game scene:
With the objects in the inventory, I want to be able to drag them to objects in the game scene (table, computer, etc) and, if the inventory objects hitTest the table AND the character, drop it. I’m working this in a different file than the briefing scene BTW.

Now I have some Qs:
- I have 3 objects inside an array called invObjects. To put them in the scene, I used a simple for that tells the program to put them in X order. They do. Just after this, I added an event listener to know where the invObject is clicked. In that function, I did: invObjects[i].startDrag() but says that the object is null, why?
- When that object is used correctly in the scene, I want it to pop(). If I pop it, those the other objects stay where they are? Pop it is the best method to be used?

I’ll appreciate any suggestion you give me. Anyway I’m working on all this.

Thanks so much guys for your help !!

PARTNERS