-
Senior Member
[AS3] Drag, Drop and Snap Inventory System
My latest AS3 drag, drop and snap inventory system.
http://www.freeactionscript.com/2011...entory-system/
Features
- Drag, drop and snap
- Create/destroy inventory containers
- Create/destroy level containers
- Move items between different movieclip containers
- Create/destroy items in level
- Create/destory items in inventory – new
- Find empty inventory slot – new
- Added item selected/diselected state – new
- Added slot full/empty state – new
- Code optimization and more comments – new
Coming Soon
- Stackable Items – items of the same type can be placed in the same slot
- Auto-pickup item – items placed in bag automatically, if bag has space
- Multiple Level containers – different game levels
- Multiple Inventory containers – bag, bank, store
- Destroy items
- Sell items
- Show Item Tooltips
Questions/comments/suggestions are always welcome!
-
formerly hooligan2001 :)
Nice works great! Looking forward to how you implement the updates.
-
Awsome the best inventory I found, and the coding is CLEAR!
This is some fine as3 code !!
I'm using your code for my game project, and it's very useful!! thx!
I could adapt it without too much problems! (I'm just starting to code in as3- started this Oct)
I arrive where i'm writing the hitTest Items in level (player run to an item in the item container (your class/movieclip "level")) and i want to check if there's empty slots in the inventory when that happens.
So I found you're function in Inventory.as :
public function findEmptySlot():Slot
But it keeps returning that it's FULL.
my inventory has 6 slots and i1 = empty, i2 = full, i3 = full, i4 = full, i5 = empty, i6 = empty. So it should return "i1" or [Object Slot] and close the function.
I verified that i had the good inventory variable from the DisplayManager (and not just the class Inventory) by using the hasitem():Boolean function from Slot.as :
var _empty_Slot:Slot = _inventory.findEmptySlot();
trace (_empty_Slot);
var _Slot1:Slot = _inventory.getSlot("i1");
trace (_Slot1.hasItem());
var _Slot2:Slot = _inventory.getSlot("i2");
trace (_Slot2.hasItem());
_empty_Slot returns null
_Slot1 returns false
_Slot2 returns true
so I'm confused
EDIT::: Here, just before posting, I figured it out!!!
Seems like the file Inventory of your package (at least the one I have, the original copy not the one I've been modifying.) has an error there:
CLASS: com.freeactionscript.inventorySystem.display.conta iner.Inventory
around line 140.
public function findEmptySlot():Slot
{
var i:int;
var tempSlot:Slot;
for (i = 0; i < _slots.length; i++)
{
tempSlot = _slots[i] as Slot;
if (tempSlot.hasItem == false)
{
return tempSlot;
}
}
trace("Inventory Full! No empty slots.");
return null;
}
I replace it by tempSlot.hasItem() == false
Check if your file on your site has this or not.
There, I continue my work, enjoying your package.. !! if i found other errors I'll post them here or send you an pm?
Cheers!
-
Senior Member
Hi JessiJames,
I'm glad you like the script!
Sorry about the bug - I don't think I was using the get empty slot function, so that's probably why it was left broken.
Replying here is just as fine a place as any. I'll make sure to apply your fix and give you the proper credit next version.
Thanks bud,
PR
P.S. sorry for the delayed reply
-
i want use function in Main.as
i want to use function
1.findEmptySlot(inventory.as)
2.DestroyInventory and DestoryLevel
all function use in Main.as
help me please
-
_inventorySystem = new InventorySystem(this);
_inventorySystem.destroyLevel(); // is wrong
_inventorySystem.findEmptySlot(_inventorySystem); // is wrong
how to use ?
Unhappy i want use function in Main.as
i want to use function
1.findEmptySlot(inventory.as)
2.DestroyInventory and DestoryLevel
all function use in Main.as
help me please
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|