I preferer the Solution from KDude. With the solution from EvilSOB you have a lot entities that use a action (are dynamic) and are in a while loop. That is bad for your fps.