More Inventory questions


(Nate ) #1

Hey guys, so I am trying to set up an inventory system for my small game. Essentially there are 9 boxes at the bottom on the screen, they are empty, and when the player picks up an item, I would like the item to appear in the inventory. As the player picks up items I would like the items to populate the next available spot, very similar to minecraft and many other inventory based games.

Also once items are in the inventory, I would like them to be right-clickable and have some options, drop/use/eat/inspect etc etc.

Is something like this doable with FlashPunk?

Thanks guys!


(azrafe7) #2

Yes! :wink: [ ](dummy text to bypass the enforce 20-char-limit)


(azrafe7) #3

You can use a Vector (or Array, etc.) to hold the items. Probably make an Inventory class managing/holding a list of Item objects. I’d also go about creating the Item (extending Entity maybe) class exposing properties such as isEdible/isUsable/etc… (along with other characteristics you may find useful - quantity/multiplier/etc.). It’s not super simple but once you wrap your mind into dividing the problem into smaller ones it becomes easier to code.

You’ll have to code your custom menu too (since FlashPunk doesn’t directly support them - although you can take a look at the punk.ui project).

I’d also want to highlight the fact the right-click support has been added (relatively) lately to Flash (added from v11.2). I should have a demo for use with FlashPunk somewhere but can’t find it right now. You can check out this article though.


(Nate ) #4

Okay thank you for the information! I will look into the punk.ui as well as the article that you supplied! :smiley: Thanks!


(Abel Toy) #5

Don’t take a look at punk.UI now. It’s really outdated. Also won’t really do anything useful for your inventory right now.

Something is coming, though…

If you want to add a custom right-button menu, you’ll have to take a look at the ContextMenu AS3 Class. There are some tutorials available on the net.