1. Hello Guest! It's with a heavy heart that we must announce the removal of the Legacy GMC Archive. If you wish to save anything from it, now's the time! Please see this topic for more information.
    Dismiss Notice

GM:S 1.4 Sprite identifying

Discussion in 'Programming' started by zendraw, Jan 27, 2017.

  1. zendraw

    zendraw Member

    Joined:
    Jun 20, 2016
    Posts:
    1,376
    so i figured the only way to identify a specific sprite in the resourse tree wuld be with sprite_get_name()
    but how do i return that string into a real value which then i wuld use to assign that sprite to an object? in the manual is suggested sprite_get_index() but such a function doesnt exist.

    is there another way or how can i get the real value from this string?

    this is a problem becouse i still add/remove sprites from the resourse trees and the saved maps i use, use the old values.
     
  2. obscene

    obscene Member

    Joined:
    Jun 21, 2016
    Posts:
    2,469
    Just simply sprite_index will return the index.

    sprite_index=spr_whatever_you_named_it

    asset_get_index will convert a string to an index.
     
  3. zendraw

    zendraw Member

    Joined:
    Jun 20, 2016
    Posts:
    1,376
    so sprite_index can be assignet to a string also? never knew that,
    edit: ive just tryed it, assignin the sprite to sprite_get_name();
    didnt change anything in the loading script, its still sprite_index=spr; and it worked.
     
  4. renex

    renex Member

    Joined:
    Jun 23, 2016
    Posts:
    506
    asset_get_index() will convert an asset name into a resource index. You can also use asset_get_type() to identify the type of resource represented by that name.
     
  5. zendraw

    zendraw Member

    Joined:
    Jun 20, 2016
    Posts:
    1,376
    yes, actually it didnt work without converting the string with asset_get_index(); didnt test it throuly
    but now ive added it and tested it and it works jsut fine.

    so basically
    spr=sprite_get_name();//save
    spr=asset_get_index(ds_grid_get(grid, x, y, i));//load
     

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