I think I may be having a problem with a runtime listener. In my TD game, I have an OnCollision function that is called by a runtime listener. This onCollision function deals with enemy walking into range-radius of defenders, enemies getting hit by projectiles and dying, and enemies encountering barricades, stopping…and starting to hack away at them.
All well and good.
But I also have a main gameloop that adds enemies per loop, checks for barricades that have been hacked through and removed in the last loop…and if so the enemy’s transition.to is reactivated so it can proceed on its way.
Now…during the onCollision function, there will be some enemies that die and some get removed, then, of course I remove them from the array (table.remove) and of course the enemy array ID numbers all shuffle down.
However…in the game loop I have a suspicion my ‘for = i to totalEnemies do…’ loops maybe being interrupted by rutime collision calls which may explain why some of my enemies are not doing what they’re told. Is that likely?
Is the answer then to set up an onCollision listener in the game loop? (and NOT make it runtime) If so…I’m a bit confused…does it HAVE to be linked to a display object or can I just do…
local LoopListener:addEventListener (“collsiion”, onCollision)
(and help will result in positive karma from me)