which is the best way to make an inventory

0 favourites
  • 12 posts
From the Asset Store
Best car suspension with spring effect and very cool terrain generation.
  • My question it's ¿which is the best way to make an inventory? specifically in a Rol-game

    Thanks for answer

    PD:// I'm Sorry by my english

  • For inventories arrays are the way to go.

    A 1D array should be enaugh. If your inventory has 100 slots, then the width of the array would be also 100. If the character picks up one item it's ID will be stored in the first emtpy array.

    Then you have to make a array-"for each element" for drawing all the items, if the user opens the inventory.

  • Thanks for all !!

    Now I know how I'll do

  • No Problem.

  • I'm gonna asking here because is related with this.

    In the game i'm developing i'm thinking in have also a store so buy some products, which the best way so save this ?

    Because i gonna have a lot of diferents images with diferences prices, and diferent values.

    I'm thinking use instance variables, but in this case i have to create 1 sprite to each image, to each text with value and shopping cart.

    Here is a example of my store with 2 products:

    thanks

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I'd use 1 sprite object and put each image item in the object frames, then create a "price" instance variable for the object for each item, create one text object (which is set to the object "price" (copy the text object so there is multiple objects of the same instance) set each text object instance variable to the name of the item you wish the price value to hold. Do check on which frame item is selected and then add/deduct price value from the relates text value. Hope that makes sense, try looking at my Zelda tutorial, it may help you.

    https://www.scirra.com/tutorials/670/ze ... e-easy-way

  • Thanks Help me a lot.

    Now i have 1 dictionary with this:

    Name-Quantity

    Food-3

    Drink-2

    1 food object (with 2 frames, 2 clones) - instance variables: name, price, foodanimation

    1 text object (2 clones) - instance variables: name

    Seems good ?

    Now i have a problem, i want enable/disable drag drop behavior according have or not this item on inventory, for that i make a for each key over dictionay, and compare the key with the instance variables of food object , but all food object turn disable :S

  • can someone help me ?

  • I would simply use a 2D array.

    The X row contains all the item information: price (X0), Infotext (X1), satiety (X2), etc.

    The Y row stands for each individual item.

    Example:

    .........X0..........................X1...............................................X2

    Y0......5............."This is a cool Item"..................................5

    Y1....14,99......"This is an even cooler Item"...................10

    Y2.....20......."This is the item you ever wanted".............15

    You than make a "for each Y element" array-loop, for creating the sprites and text. Set their sprite to array.CurY (this is the Y position of each item in the array and simultaneously the ID).

    You only need 1 sprite object (with all frames for all items) and 1 text object for all items.

    Edit:

    For the drag & drop I would do something like this:

    If object is overlapping the background of the shop menu

    • on key press: activate drag & drop behaviour
    • on key release: deactivate drag & drop behaviour
  • I've not done a drag and drop feature before, so not sure, maybe post a screen shot of the code?

  • I have this:

    When i do this all foodicon disable the drag and drop feature.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)