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

GM:S 1.4 If I deactivate an instance, can I still draw it? (instance_deactivate_object)

Discussion in 'Programming' started by Dr_Nomz, Dec 3, 2019.

  1. Dr_Nomz

    Dr_Nomz Member

    Joined:
    Oct 31, 2016
    Posts:
    619
    It's a GREAT function for pausing, but I kinda still need to SEE the thing while it's paused. Is that possible?
     
  2. JackTurbo

    JackTurbo Member

    Joined:
    Oct 19, 2016
    Posts:
    827
    Draw it to a surface before deactivating is the general approach for pausing via deactivating.
     
  3. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    7,136
    the alternative, if you are not going to have too many instances that you need to draw while deactivated, is to store the ID of every instance you need to still draw while deactivated in an array or list. then you loop through said array or list, store the saved ID at each entry in a temporary variable, then use that variable to pass all of the proper instance variables to a normal draw_sprite call. Actually, you may want to use a priority queue since you may want to preserve depth.
     
  4. Catastrophe

    Catastrophe Member

    Joined:
    Sep 22, 2019
    Posts:
    222
    An issue with surface drawing is alpha/blending borking up unless you're an GM wizard, so theouAegis' idea may be the better method anyways if you are planning on needing to draw things correctly. If everything is opaque without blending, the surface method is the easiest way probably, though.

    Gross thought: I think you'd have to order everything by depth if you're using either of these methods.

    2 other methods if you're interested that don't involve deacto:

    1) the way I do it which is just make a while(true) loop with io updates and screen redraws, there's menu tutorials based on while(true) loops if that is what you need. No deactivation necessary

    2) Make dummy objects that copy their depth/sprite/image_index/alpha/blend/x/y before deactivation and destroy them all afterwards. You can make this code super light by just doing a

    with (all){ make dummy } and then with (dummy) {instance_destroy()} after pause


    Pretty much any method other than the while(true) method will mean you are unable to use the draw event of the spoofed objects, though, so the while (true) method may be the only suitable method for your game.
     
    Last edited: Dec 3, 2019

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