• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker Getting sprite's "order in list" (SOLVED)

I'm lost

Member
So..
I am trying to draw_sprite() by inserting the sprite id instead of sprite name like spr_apple.

But I discovered, sprite id isnt exactly what I want, because
Code:
item = spr_apple.id

draw_sprite(item,image_index,x,y);
doesnt work.


Sprite id looks like 100028 or 100020.

What I want is a sprite order in sprite list.
Lets pretend, that spr_apple is third in list, so the list looks like:
1. spr_player
2. spr_enemy
3. spr_apple
4. spr_gun
5. spr_obstacle

Sprites orders in list are:
1. spr_player...............0......\
2. spr_enemy..............1........\
3. spr_apple................2.........> I WANT TO GET THESE NUMBERS
4. spr_gun...................3......./
5. spr_obstacle............4...../

Inserting order in list of sprite in draw_sprite() works.
Code:
item = 2

draw_sprite(item,image_index,x,y);
Then, the code will draw me an apple.

Isnt there any function or something, to get these numbers, something like sprite_get_order ?
 
Did you try this yet instead of hypothesizing? Your claim is completely off and as a result you don't realize that you are already giving the answer you're looking for. Sprite numbers already contain the id you desire, the name is just the representation for it so you can type spr_apple instead of having to remember the number or reference a list containing it. It's only instances that start at such a high number and are unique since instances are just "copies" of an object. Put in draw_text(0,0,spr_apple) and you'll see it's the exact number you're looking for.
 
Top