Is it possible to spawn objects faster as the game progresses? If so, what’s the function for it and how do you do it? What’s the most efficient way? If it’s not possible, please tell me. If it is possible, can you please give some sample code? Thanks so much.
Something like this?
You could extend it to use a second timer which changes the spawn rate every so often, rather than at the point of each spawn.
[lua]
local spawnTimer = system.getTimer()
local spawnRate = 2000
local gameLoop = function ()
local t = system.getTimer
if t - spawnTimer > spawnRate then
– spawn object
spawnTimer = system.getTimer()
spawnRate = spawnRate - 50
end
end
Runtime:addEventListener(“enterFrame”,gameLoop)
[/lua]
Yes, the code works fine! The only error in the code was the ‘local t = system.getTimer’ instead of ‘local t = system.getTimer()’. But that was easy to find and fix. Thank you so much for the help and code!
Something like this?
You could extend it to use a second timer which changes the spawn rate every so often, rather than at the point of each spawn.
[lua]
local spawnTimer = system.getTimer()
local spawnRate = 2000
local gameLoop = function ()
local t = system.getTimer
if t - spawnTimer > spawnRate then
– spawn object
spawnTimer = system.getTimer()
spawnRate = spawnRate - 50
end
end
Runtime:addEventListener(“enterFrame”,gameLoop)
[/lua]
Yes, the code works fine! The only error in the code was the ‘local t = system.getTimer’ instead of ‘local t = system.getTimer()’. But that was easy to find and fix. Thank you so much for the help and code!