I am making a tower defense game in Flash and I have a slow tower that is built directly on the path. I have it setup to use a hitTestObject function.
The tower is in its own class and the enemies are in their own class.
In the update function for the tower, it has
if (this.hitTestObject(enemy))
{
enemy.slow = true;
}
In the enemy class update function, I have:
if (slow == true)
{
finalSpeed = speed/2;
}
else
{
finalSpeed = speed;
}
This seems to work fine until I build a second slow tower. Whenever I build the second one, it works, but the first one stops working (it no longer slows enemies). However, it is still detecting the collisions with the enemies. I don't understand why it doesn't slow them down though.