• 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 Draw a sprite with GUI, play the animation, and then delete it

K

kingjohnc19

Guest
put a blank draw event, draw_self() in the gui event, instance_destroy in the animation end event.
I'm trying to draw the GUI slightly above the player. how would I set a position for it? I tried doing it with an object instead of a GUI sprite, but it wasn't always exactly on top of the player.
 

samspade

Member
I'm trying to draw the GUI slightly above the player. how would I set a position for it? I tried doing it with an object instead of a GUI sprite, but it wasn't always exactly on top of the player.
If you want it above the player, don't use the GUI layer. The GUI layer uses a different coordinate system which doesn't even necessarily correspond to the view.

What does not always exactly on top of the player mean?
 
K

kingjohnc19

Guest
If you want it above the player, don't use the GUI layer. The GUI layer uses a different coordinate system which doesn't even necessarily correspond to the view.

What does not always exactly on top of the player mean?
basically it doesn't stay above the player and seems to lag behind a lot.
 

Joe Ellis

Member
Ah yeah thats cus when you draw in the gui event it just draws in screen coords without using the view that most of the game is using, which is what you want for a menu or something, but if you want something to hover about the player, it'd be easiest to make a normal object and draw in the normal draw event, and just make sure the depth is -2000 or something so it'll always be in front of everything

Also for deleting the sprite\instance when it's finished the animation, you can use the "animation end" event, and do instance destroy in that, or ask if image_index > image_number -1, and make two copies of the final frame, so when it reaches the last frame, it's done and will delete the object

PS sorry for interupting
 
Last edited:

samspade

Member
basically it doesn't stay above the player and seems to lag behind a lot.
That sounds like an issue with when you are updating its coordinantes. Try moving that to either the end step event (assuming the player updates in the normal step).
 
Top