gasilpit.blogg.se

Gamemaker studio 2 for loop
Gamemaker studio 2 for loop







GAMEMAKER STUDIO 2 FOR LOOP CODE

Unless this code is not the complete thing. You're sorting a sprite in var sprite but when you use draw_sprite you draw it with the for loop. I've certainly had that happen before.Īlso you appear to not use argument0 or argument1 at all. If you always do this then that may cause unintended issues elsewhere. The "<=" could be part of the problem because what that is saying is "if i is less than or equal to total slots, then continue the loop." But that may be producing more loops than intended? I can't be sure because you don't define inv.total_slots in the code there.Īnother possible thing is when defining i you define it as an instance variable and not a local variable. Other things that are probably nothing major, but maybe?: Does each item have it's own? Can you post a screenshot of what it looks like so we can have a better understanding of what the code you posted even does?

gamemaker studio 2 for loop

I'm not really sure I understand the way you're doing your coordinates either. This would check to see if "global.inventory" returns something other than -1 and only draws if it does.

gamemaker studio 2 for loop

Couldn't you just do this?: if( global.inventory != -1 )ĭraw_sprite( sprite, 0, inv.coordX + 6, inv.coordY + 6) ĭraw_text(inv.coordX + 16, inv.coordY - 30, string(global.inventory)) ĭraw_text(inv.coordX - 16, inv.coordY - 16, string(global.inventory)) It looks like all you're doing is drawing the info for an item that is called by the script. I can't say for GMS2, but I have noticed some things:įirst let's clear some stuff up: why do you need to use a for loop here at all?







Gamemaker studio 2 for loop