Okay, so I am making a death star replica (go star wars) and I want it to fire its awesome laser. If other death stars cross the laser’s path, then they will get blown up. The problem is that collideLine only accounts for the first entity hit in the line, and because the death star has the same type as the other death stars (must be this way), it will register itself as the first entity hit with the collideLine function. The line starts from the death star’s center and goes in a random direction.
/*All of this code is in the laser.as*/
//The creator is set as the death star creating this laser
var creator:DeathStar = DeathStar;
//Find the first collided entity in a line
var ds:DeathStar = DeathStar(FP.world.collideLine("deathstar", creator.x, creator.y, targetX, targetY));
if (ds != null)
{
//Blow up the collided death star with damage and acknowledge who the creator was
ds.blowUp(damage, creator);
}
Now if I could just ignore the creator with something like
if (ds != null && ds != creator)
{
//Blabla
}
then life would be great. But since collideLine still only registers the creator as the only entity hitting the line, even if it doesn’t damage the creator, it won’t check for collisions with other entities.
Now a possible solution would be to make an alternative to collideLine, something like collideLineInto (like there is for collideRect and collideRectInto), but after trying to make a function like that for around 1 hour now, I am still at step 1. The easiest solution would be to ignore the creator entirely with the collideLine function and then only check for one collision in the line, since I only want to blow up one death star at a time anyway.
Any ideas?