• Hey! Guest! The 40th (!!!) GMC Jam will take place between February 25th, 12:00 UTC to March 1st 12:00 UTC. Why not join in this very special anniversary jam! Click here to find out more!

GMS 2.3+ Draw GUI

Amigo121

Member
Hello, I tried to make Draw GUI event for my game. I actually got it to work but when i change the sprite ( in draw_sprite() ) it draws empty space.

Draw GUI code:
GML:
var xx = room_width - 32;
repeat(global.ammo)
{
    draw_sprite(sShell, 0, xx, room_height - 32);
    xx -= 32;
}
I am not sure why it is like that, any ideas?
P.S.: Both sprites do exist (the working and not working one), only difference is in sprite colour.
w_sShell.pngw_sShellE.png
 
Last edited:

Rob

Member
Are the origin points in the sprites the same? [Edit] looks like they are... One thing you can do to test then is just to replace the sprite (copy the sprite over from the one that doesn't work to the one that does). If the sprites are the same except for colour, why not just use the same sprite and change the image_index that's being drawn instead anyway? I don't have enough info to tell you why you can't see the second sprite atm.

I would also advise using the display_get_gui_width() and display_get_gui_height() functions to determine the draw coordinates for the GUI layer as using room coordinates can also create problems like the one you've described. GUI coordinates remain the same regardless of where you are in a room and if you have a game with rooms of different sizes your draw coordinates will be thrown off the way you have it now.
 
Last edited:

Amigo121

Member
Are the origin points in the sprites the same? [Edit] looks like they are... One thing you can do to test then is just to replace the sprite (copy the sprite over from the one that doesn't work to the one that does). If the sprites are the same except for colour, why not just use the same sprite and change the image_index that's being drawn instead anyway? I don't have enough info to tell you why you can't see the second sprite atm.

I would also advise using the display_get_gui_width() and display_get_gui_height() functions to determine the draw coordinates for the GUI layer as using room coordinates can also create problems like the one you've described. GUI coordinates remain the same regardless of where you are in a room and if you have a game with rooms of different sizes your draw coordinates will be thrown off the way you have it now.
Thanks for your helpful comment!
 

Amigo121

Member
No problem - is everything working now?
It was helpful comment, however I could not follow it or fully understand it.
I think image_index is mostly used in animation (when you have more frames assigned to sprite). If you wanted me to put these 2 sprites together and just select the wanted image_index I do not think I can (know how to) do that.
Thank you for reminding me about the display_get_gui_width() and display_get_gui_height() although I think in this specific situation it is not required (I do not use camera system so the room size should equal to gui) => (room size equals to my screen resolution as well, maybe not reliable for other devices, I dunno).
 
Top