quattj
Member
I have a master game controller, it runs this script in the begin step.
It deactivates anything outside of the view, then reactivates all blocks (stage pieces), then deactivates what remains in an area 80 larger than the view in each direction so there is a buffer for anything that bleeds over the edges and is still active. This keeps all blocks around the play area "existing" when enemies and such are then reactivated in the view.
My problem comes when there are enemies above the top of the screen, but still in the active zone, but they shouldn't technically "be there" until the stage scrolls upwards a little more.
To try to solve this, I created a stand-alone deactivator, which has a check in its begin step, step, and end step for enemies at its location.
This "appears" to work. I can not see the enemies on the screen until the deactivator object is destroyed. Buuut, there is a skeleton that throws bones on a timer. Once the stage scrolls to where the skeleton is properly formed (deactivator destroyed) there is a huge pile of projectile bones waiting to explode everywhere, bones that should not exist if the skeleton was properly deactivated.
Looking for suggestions on how I can tame this beast. I was thinking of adding a variable to enemies for keeping them deactive, but I think that wouldn't work because if they are not active, the variable can't be read anyway.
GML:
function room_activate()
{
instance_deactivate_region(view_left(), view_top(), view_width(), view_height(), false, true);
instance_activate_object(obj_base_block);
instance_deactivate_region(view_left()-80, view_top()-80, view_width()+160, view_height()+160, false, true);
instance_activate_object(obj_tracker);
instance_activate_object(obj_weapon);
instance_activate_object(obj_weapon_onehit);
instance_activate_region(view_left(), view_top(), view_width(), view_height(), true);
instance_activate_object(obj_base_ctrl);
instance_activate_object(obj_base_ship);
instance_activate_object(obj_checkpoint);
instance_activate_object(obj_player_continuespot);
instance_activate_object(obj_deactivator);
}
My problem comes when there are enemies above the top of the screen, but still in the active zone, but they shouldn't technically "be there" until the stage scrolls upwards a little more.
To try to solve this, I created a stand-alone deactivator, which has a check in its begin step, step, and end step for enemies at its location.
Code:
baddie = instance_place(x, y, obj_weapontarget);
if (baddie)
instance_deactivate_object(baddie);
Looking for suggestions on how I can tame this beast. I was thinking of adding a variable to enemies for keeping them deactive, but I think that wouldn't work because if they are not active, the variable can't be read anyway.