This example demonstrates the basis for a simple Tower Defence game. Towers will shoot at the closest enemy when that enemy comes within a distance of 100 pixels away.
This example supports unlimited enemies and towers created at runtime.
It may not be the most efficient method because it always runs loops, however this could be optimized.
I made this example for jthongbai on The Daily Click.