Deactivating instances keeps them deactivated.

N

NoFontNL

Guest
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 by a moderator:
N

NoFontNL

Guest
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)
 
Top