Deactivating instances keeps them deactivated.

Discussion in 'Programming' started by NoFontNL, Aug 14, 2019 at 9:53 AM.

  1. NoFontNL

    NoFontNL Member

    Joined:
    Feb 10, 2018
    Posts:
    287
    Hi all, I deactivate instances and they stay deactivated. That's strange, since I always activate the region of the view.
    This is the code.
    Code:
    var offset =320;
    instance_deactivate_region(view_xview-2*offset,view_yview-4*offset,view_wview+4*offset,view_hview+8*offset,false,true);
    
    instance_activate_region(view_xview-2*offset,view_yview-4*offset,view_wview+4*offset,view_hview+8*offset,true)
    
    instance_activate_region(obPlayer.bbox_left,0,obPlayer.sprite_width,room_height,true)
    instance_activate_object(obj_ex_audio);
    instance_activate_object(obShowBlock);
    instance_activate_object(obDrawShadow);
    instance_activate_object(par_ui);
    instance_activate_object(obDarkenScreen);
    instance_activate_object(par_liquid);
    instance_activate_object(obLiquidLevelSlider);
    instance_activate_object(obLiquidLevelMaxSlider);
    
    This only occurs when switching areas.
     
    Last edited: Aug 14, 2019 at 10:22 AM
  2. TheSly

    TheSly Member

    Joined:
    Jan 16, 2017
    Posts:
    947
    maybe try using shift-ctrl F to search through your whole project for the word 'deactivate'.
     
  3. NoFontNL

    NoFontNL Member

    Joined:
    Feb 10, 2018
    Posts:
    287
    Thanks, I found the cause, now the problem is that when switching areas, that the deactivation keeps instances deactivated for some reason.
    I save the objects in a map.
    Code:
    ///change_area(n)
    
    
    var pendingArea=argument[0];
    var currentArea=global.area;
    
    global.area=pendingArea;
    for (var i=ds_map_find_first(global.levelMap[currentArea]); !is_undefined(i); i=ds_map_find_next(global.levelMap[currentArea],i)){
        var inst = real(i);
       
        if(is_undefined(inst)) continue;
        if(!instance_exists(inst)) continue;
       
        var _newy = inst.start_y + (2+global.area)*room_height;
        if(object_is_ancestor(inst.object_index,par_gameObject)) {
            inst.y=_newy;
        }
    }
    
    for (var i=ds_map_find_first(global.levelMap[pendingArea]); !is_undefined(i); i=ds_map_find_next(global.levelMap[pendingArea],i)){
        var inst = real(i);
       
        if(is_undefined(inst)) continue;
        if(!instance_exists(inst)) continue;
       
        if(object_is_ancestor(inst.object_index,par_gameObject)) {
            inst.y=inst.start_y;
        }
       
        instance_activate_object(inst);
    }
    
    
    
    But when switching, the objects move to their place, but don't activate (not even after 10 seconds) and I activate all instances every 30 steps (of 60)
     

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