• 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!

SOLVED I want to make the enumerator correspond to the item sprite

U

uni00

Guest
Hello. We are making an inventory. The image is a picture of the item used for inventory. I draw a picture every 64 pixels. I want to use draw_sprite(); according to the order of enumerators below.
How can I make this sprite an enumerator?

GML:
enum item{
none,
draw_set,
mirror,
ball_w,
ball_b,
ueki,
tubo,
tue,
kagi,
kami,
total
}
GML:
global.inv = ds_grid_create(4,2);
ds_grid_clear(global.inv,0);

var_slot=0;

var slot = 0;
while (slot < ds_grid_width(global.inv))
{
var inst = instance_create_layer(x+8+(20*slot), y+8, "Instances", obj_btn);
inst.var_slot = slot;
slot ++;
}
GML:
var iid = global.inv[# var_slot,0];
var amount = global.inv[# var_slot,1];
var name = global.item_index[# iid,item_stat.name];
var description = global.item_index[# iid, item_stat.description];

if(iid != item.none){
draw_sprite(spr_item, iid, x,y);
draw_text(x+4,y+9,string(amount));
draw_text(x+6,y,string(name));
draw_text(x+6,y+4,string(description));
}


スクリーンショット (123).png
 

Roldy

Member
I don't understand your question. What exactly is your issue?

My first guess is that you don't have your sprite setup correctly.

draw_sprite ( sprite, SUBINDEX, x, y);

Your sprite only has one frame. I believe you will want to break that image up into separate frames so SUBINDEX can point to the correct image.

Your sprite, spr_item, needs 9 (or ten) frames.

If you keep item.none (zero, a blank frame) then you will need ten frames.

But that is just a guess at what your issue is.

If that is not the problem then ask again with more information about what is going on. Post a screen shot of what is actually getting drawn.
 
Last edited:
Have a look at

Draw_Sprite_Part_Ext()
Sprite_Get_Width()
Sprite_Get_Height()

And calculate the size of each image in the frame of the sprite. such as cellsize = 16 // (16x16) eg.

You'll need to setup a few variables in the create event of the inventory object.

Ensure the first square in the sprite is blank because this will be the 'none' part of the enum.

Lastly make sure you delete the data structure in the cleanup event.

I can't comment on your code because I don't fully understand it. I'm sure someone else may advise you with that.
 
Top