GMS 2 SOLVED sprite in a ds_map.

Discussion in 'Programming' started by Michael Hart, Mar 15, 2019 at 4:36 AM.

  1. Michael Hart

    Michael Hart Member

    Joined:
    Jun 23, 2016
    Posts:
    88
    Id like to put a sprite in the ds_map
    //sc_additem
    var name = argument0;
    var sprite = argument1;
    var amount = argument2;

    var inv = ds_map_create():
    ds_map_add(inv, "name", name)
    ds_map_add(inv, "sprite", sprite)
    ds_map_add(inv, "amount", amount)

    ds_list_add(global.inventory,inv)


    global.inventory = ds_list_create();
    sc_additem("apple", sp_apple, 4)
    or is it
    sc_additem("apple", "sp_apple", 4)

    i want to do something like
    for (var i = 0; i < ds_list_size(global.inventory); i +=1)
    {
    var obj = instance_create_depth(x,y+(i*150),depth,ob_inven_slot)
    }

    ultimately each item will have its own sprite nut for some reason cannot get the sprite as part of the map
    suggestions?
     
  2. Dmi7ry

    Dmi7ry Member

    Joined:
    Jun 24, 2016
    Posts:
    478
    Yes, you can do it (but only if you won't save the map using ds_map_write, etc).
     
  3. Michael Hart

    Michael Hart Member

    Joined:
    Jun 23, 2016
    Posts:
    88
    thanks got it working
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice