I’m making a tower defence game and need to leave a gap between each enemy in the wave. I am trying to use this code
function Wave:sendwave(w) for i = 1, #waves[w] do if waves[w][i] == "bug" then --reads the current enemy in the wave local column = math.random(1,5) -- sets a random column tween.delay(1, function() enemies[i] = Enemy(WIDTH,column*90 +100,col,"bug") end) --spawns a bug end end end
Each enemy should spawn one second after each other but they all start at the same time. Is this because I am starting all the delays off at the same time? And how can I resolve this issue?