GMS 2 (Solved) activate and deactivate instance by id

Discussion in 'Programming' started by Shadowblitz16, Jun 7, 2017.

  1. Shadowblitz16

    Shadowblitz16 Member

    Joined:
    Jun 23, 2016
    Posts:
    601
    does anybody know how to deactivate and activate a instance by id?
    Code:
    /// @description Insert description here
    // You can write your code in this editor
    
    event_inherited()
    
    var dx1 = screen_y;
    var dy1 = screen_x;
    var dx2 = screen_y+screen_height/16;
    var dy2 = screen_x+screen_width/16;
    
    for (var cy=dy1; cy<dy2; cy++)
    for (var cx=dx1; cx<dx2; cx++)
    {
        var combo = Game.combos[# cx, cy];
        var cx1   = combo.x;
        var cy1   = combo.y;
        var cx2   = combo.x+16;
        var cy2   = combo.y+16;
       
        if (cx1 < dx2 && cy1 < dy2 && cx2 >= dx1 && cy2 >= dy1) 
            instance_activate_object(combo);
        else
            instance_deactivate_object(combo);
           
        if (combo != undefined)
            draw_tile(combo.tileset, combo.tile, 0, (x+1)+(cx*16), (y+1)+(cy*16));
        else
            draw_sprite(spr_null, /*ALIGNMENT*/  0, (x+1)+(cx*16), (y+1)+(cy*16));
    }
    
     
  2. NightFrost

    NightFrost Member

    Joined:
    Jun 24, 2016
    Posts:
    2,064
    You provide instance_(de)activate_object with an instance id. It reads so right in the manual.
     
  3. Shadowblitz16

    Shadowblitz16 Member

    Joined:
    Jun 23, 2016
    Posts:
    601
    combo is an instance id
    also i'm not sure what was wrong but I got it. thankyou
     

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