PDA

View Full Version : Help needed with making an inventory



nick5014
January 21st, 2010, 04:45 PM
Hi all, im new to this forum and new to as3, moving up from as2. I could really do with some help getting an inventory to work between frames for an adventure game im trying to make. I have attatched a demo of my inventory and its problems to this post and was hoping some kind person could help me.

The inventory works great for one frame, but when you go to another frame or back to the first frame it breaks.. Im really at a loss of how to go forward now as i dont think i can make a game in just one frame.

The inventory works by adding a declared item into an array when clicked on, then moving that item into an "inventory" at the bottom of the screen.

What I want to do is pick up items, move to the next frame, pick up some more, then go back to the previous frame and not see the items on the screen anywhere except in my inventory.

If someone could take a look at the example inventory I have posted I would be really really gratefull. It is two frames with four items named box1,box2,box3,box4. You can go back and forth between frames but are only able to pick up items on the first frame.

Nick

Robbe
January 21st, 2010, 08:05 PM
I'm also doing an adventure game, and yes - it can all be done in one frame. In reality - frames are merely there for animation purposes. Programming languages don't use frames.

What I would suggest to you and what I'm doing with my game, is this -
a) decide if you want the data to persist infinitely (i.e. not just for the instance in which the game is played),
b) what purposes are you using that frames offer but as does not?

The answer to these will lead you to MANY more design questions.

In the case of your inventory, the way I have looked at it is that via SQL. All my game variables load from SQL (though I have used XML many times in the past). All levels are controlled by tables that describe items in that level, while items are populated in random. There are also player tables, NPC tables, etc.

For your inventory, the same applies. Pick up an item, and you register that in your SQL, drop the item and it is deleted from inventory. This way you can store infinite values for each item such as you would see in EQ2, WoW, SWG, or any MMORPG adventure game. The "physical" boxes are merely location mirrors in the DB. If there are a specified number of an item in world, you subtract it from that table in SQL when it's picked up, and add it to your player table.

Just some thoughts, and I'm def NOT a great AS programmer - but through the help of many here and many other forums, I get by =)

Good luck and I'll be watching to see how it's coming along for you!

/r

nick5014
January 22nd, 2010, 03:08 PM
Thanks a lot Robbe! I was sure i could never do everything in 1 frame, but after your post i understand that i just thought i couldnt. I was just using frames to break up each scene for me as it was something I was so used to doing, but it really isnt needed. Il let you know how it all goes.

Many thanks

Nick