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

How to make a Save Icon on HUD?

P

polartropics

Guest
So i've tried for days but i cannot get this to work. I hate the pop up box with text that interrupts the game but i have no way of showing that the game did save. So i want to make a save icon appear at the bottom of the screen when saved.
Now this is so tricky because the pause menu is handled in the step event but the HUD is handled in the draw GUI event (obviously) So the issue im having is, how do i make a sprite appear at the bottom right of the screen when something in the step event is chosen. I have no idea.

Not intentially trying to complicate things, but i had the idea (before starting this of course) of what if the save icon was instead a tiny animation that lasted a few seconds and there were like 20, and one was chosen at random. i used the draw_sprite() just to test if anything was even being drawn, it was just at all times. i put irandom (si-1) as the sprite_index and the code i guess just randomly cycled through all of them endlessly changing 20 times a second. so if its possible, how would i also make the sprite chosen be one of 20 and only play one then dissapear.

If anyone has any ideas please let me know, ive been working on this for so long im about to give up. Thanks in advance to all.
 
O

Old_Bean

Guest
I'm not sure if this totally covers what you need but it at least should play a save animation from a selection of 16 in the bottom right of the screen when triggered by your save event. If you really want 20 animations then swap the choose function with a switch statement or something.

////////step event when saving occurs
save_anim_length = 10////number of frames in the anim
current_save_frame = 0;
save_anim = choose(spr_save_01, spr_save_02, spr_save_03, spr_save_04, spr_save_05); //// fill this with your save animations. Choose function is limited to a maximum of 16.

///////draw_gui_event
if current_save_frame <= save_anim_length {
draw_sprite(save_anim, floor(current_save_frame),view_wview[0]-20,view_hview[0]-20);
current_save_frame += 0.3////change this to increase/decrease the speed of the anim
}
 
Another approach would be using an object for the animation.

Make a sprite with subimages for your animated save-symbol.
Create an object, name it i.e. obj_save_animation and assign the sprite to it

In create event:
alarm[0] = room_speed; // times how many seconds the animation should show
image_speed = 0.5; // or whatever you like here​

In alarm 0 event:
instance_destroy();​

In Draw event just put a code with no action:
/// don't draw me​

In Draw GUI event:
// factor 2 to give the sprite some offset. Change if you want more or less offset
draw_sprite(sprite_index, image_index, display_get_gui_width() - sprite_width * 2, display_get_gui_height() - sprite_height * 2);​


In the code where you save the game put this in:
instance_create(0, 0, obj_save_animation);
So whenever your game saves it will create an object that shows the symbol for a specific time and then destroys itself. This way you have a very clean code by clearly seperating the animation from the saving and it'll be easier to make changes later.

If you're switching to GMS 2 you'll need to change that instance_create line.

Edit: forgot about the randomnes of the sprite. In create event you'd also add:
sprite_index = choose(spr_save_01, spr_save_02, spr_save_03, spr_save_04, spr_save_05);
 
Last edited:
P

polartropics

Guest
I'm not sure if this totally covers what you need but it at least should play a save animation from a selection of 16 in the bottom right of the screen when triggered by your save event. If you really want 20 animations then swap the choose function with a switch statement or something.

////////step event when saving occurs
save_anim_length = 10////number of frames in the anim
current_save_frame = 0;
save_anim = choose(spr_save_01, spr_save_02, spr_save_03, spr_save_04, spr_save_05); //// fill this with your save animations. Choose function is limited to a maximum of 16.

///////draw_gui_event
if current_save_frame <= save_anim_length {
draw_sprite(save_anim, floor(current_save_frame),view_wview[0]-20,view_hview[0]-20);
current_save_frame += 0.3////change this to increase/decrease the speed of the anim
}
Thanks! This didnt work at first because the save systems layered in a lot of scripts and objects and rooms, so i had to do some debugging and rearranging but it works! 16 animations is fine, 20 was a rough estimate so this is perfect. Thank you so much!
 
P

polartropics

Guest
Another approach would be using an object for the animation.

Make a sprite with subimages for your animated save-symbol.
Create an object, name it i.e. obj_save_animation and assign the sprite to it

In create event:
alarm[0] = room_speed; // times how many seconds the animation should show
image_speed = 0.5; // or whatever you like here​

In alarm 0 event:
instance_destroy();​

In Draw event just put a code with no action:
/// don't draw me​

In Draw GUI event:
// factor 2 to give the sprite some offset. Change if you want more or less offset
draw_sprite(sprite_index, image_index, display_get_gui_width() - sprite_width * 2, display_get_gui_height() - sprite_height * 2);​


In the code where you save the game put this in:
instance_create(0, 0, obj_save_animation);
So whenever your game saves it will create an object that shows the symbol for a specific time and then destroys itself. This way you have a very clean code by clearly seperating the animation from the saving and it'll be easier to make changes later.

If you're switching to GMS 2 you'll need to change that instance_create line.
thanks for the suggestion! i got it working but if i need to add more, or need some more control ill definitely come back to this, Thanks!
 
Top