Hello,
I have an enemy spawner function being called with performWithDelay. I am passing the function name and the number of enemies to spawn, but for some reason the function only runs once… any ideas on why?
local function spawnEnemies(enemyType) print("Running spawnEnemies Function") local path = gameBoard.\_path -- local random = random local enemyType = enemyType local params = {spawnX=x, spawnY=y, enemyType=enemyType, path=path} --EnemyTable[#EnemyTable+1] = Enemy:new(group, params) local myEnemy = Enemy:new(group,params) -- EnemyTable[#EnemyTable]:ChangeSpeed() --print("Enemy Built!") myEnemy=nil end print("Spawning: "..totalEnemies.." level "..enemyType.." enemies.") local mySpawnEnemies = spawnEnemies(enemyType) local spawnEnemiesTmr = timer.performWithDelay(1000, mySpawnEnemies, totalEnemies)
The output shows:
Spawning: 10 level 1 enemies.
Running spawnEnemies Function
Where it should show something like:
Spawning: 10 level 1 enemies.
Running spawnEnemies Function
Running spawnEnemies Function
Running spawnEnemies Function
Running spawnEnemies Function
Running spawnEnemies Function
Running spawnEnemies Function
Running spawnEnemies Function
Running spawnEnemies Function
Running spawnEnemies Function
Running spawnEnemies Function