This site requires JavaScript, please enable it in your browser!
Greenfoot back
DMCGames
DMCGames wrote ...

2012/2/24

Inventory

DMCGames DMCGames

2012/2/24

#
Hi, I'm trying to make an inventory, holding everything that the player collects, but I need each individual box to hold just one item. The only idea I can think of is to make a separate box for each box in the inventory, and get the intersecting object to be added to the players class, so when you press "I" for inventory everything will be there and can be updated when the inventory is closed.
DonaldDuck DonaldDuck

2012/2/27

#
I would create an object inventory (an actor, but remove the extends Actor to make it an "other class") and inside of it make a static array called inv. You can make the array as large as you want inventory slots. Everything in this class must be static and can be called from another class by saying inventory.something or you can write inventory i = new inventory; i.something and not need to have statics. The advantage to the second method is that the variables will be reset with the program instead of having to write a reset method for it.
You need to login to post a reply.