1. Hello Guest! It's with a heavy heart that we must announce the removal of the Legacy GMC Archive. If you wish to save anything from it, now's the time! Please see this topic for more information.
    Dismiss Notice

GMS 2 Draw a sprite with GUI, play the animation, and then delete it

Discussion in 'Programming' started by kingjohnc19, May 31, 2019.

Tags:
  1. kingjohnc19

    kingjohnc19 Member

    Joined:
    Mar 12, 2019
    Posts:
    24
    How would I do that?
     
  2. samspade

    samspade Member

    Joined:
    Feb 26, 2017
    Posts:
    2,110
    put a blank draw event, draw_self() in the gui event, instance_destroy in the animation end event.
     
  3. kingjohnc19

    kingjohnc19 Member

    Joined:
    Mar 12, 2019
    Posts:
    24
    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.
     
  4. samspade

    samspade Member

    Joined:
    Feb 26, 2017
    Posts:
    2,110
    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?
     
  5. kingjohnc19

    kingjohnc19 Member

    Joined:
    Mar 12, 2019
    Posts:
    24
    basically it doesn't stay above the player and seems to lag behind a lot.
     
  6. Joe Ellis

    Joe Ellis Member

    Joined:
    Aug 30, 2016
    Posts:
    988
    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: Jun 1, 2019
  7. samspade

    samspade Member

    Joined:
    Feb 26, 2017
    Posts:
    2,110
    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).
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice