out of view destroy with different views

T

TRANEPRODUCTIONS

Guest
Need a little bit of help from you guys trying to choose a bullet that gets destroyed if it's out of two views. It's goes something like this

If x < xview1 || x > xview1+wview1 ||
y < yview1 || y > yview1+hview1{
Instance_destroy();
}

How can I check the second view without it being destroyed because of the first view?
 

Binsk

Member
Well, I'm not sure what you are trying to accomplish so there could be several ways to do this. Let's assume you want to destroy the bullet iff (if and only if) it is outside both of the views. What you need to do is check the first view and record if it was true or false. Then, check the second view and record if it is true and false. Lastly you check both of your records and if they are both true you destroy the bullet.

Now, there are simpler and shorter ways to do this with fewer variables, but this should hopefully make the most sense to you. It would be something like this:
Code:
// Create two temporary variables to be our records:
var isOutsideView1 = false;
var isOutsideView2 = false;

// Check if we are outside the first view and set the record:
if (x < xview1 || etc...)
    isOutsideView1 = true;

// Do the same for the second view
if (x < xview2 || etc...)
    isOutsideView2 = true;

// Now check the records to see if we must destroy the bullet:
if (isOutsideView1 && isOutsideView2)
    instance_destroy();
That's all there is to it!
 
M

maratae

Guest
Need a little bit of help from you guys trying to choose a bullet that gets destroyed if it's out of two views. It's goes something like this

If x < xview1 || x > xview1+wview1 ||
y < yview1 || y > yview1+hview1{
Instance_destroy();
}

How can I check the second view without it being destroyed because of the first view?
Code:
// Get an active view:
current_view = 0;

// Destroy if out of the active view
if (x < view_xview[current_view] || x > view_xview[current_view] + view_wview[current_view])
{
    instance_destroy();
}
 
T

TRANEPRODUCTIONS

Guest
Thanks you guys made it seem so easy I was just over thinking it I appreciate it!
 
P

ParodyKnaveBob

Guest
You know you have Outside View Events, right? $:^ }

I hope this helps,
Bob
 
Top