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

2012/4/7

adding a copy of itself

Razzo Razzo

2012/4/7

#
I've been using an ArrayList for an Inventory, And bound to each item is a variable; amt, (Amount) When I drop something, I want it to, if amt > 1; addClone if amt == 1; addItself.. Ive been doing this but I dont know how to add its own class.. This is what I have been doing
    public static void removeItem(Interactive i)
    {
        if(i.amt > 1) i.amt--;
        else inventory.remove(i);
    }
    
    public void place(Interactive i)
    {
        removeItem(i);
        getWorld().addObject(i, GuiItem.px, GuiItem.py);
    }
You need to login to post a reply.