Basically I have a function that generates objects on the screen, I used timer.performWithDelay() to generate those objects at a set rate of time. I would prefer that these objects spawn at a rate that increases as the game goes on, so I was wondering if it were possible to change the rate at which the timer.performWithDelay() functions (like instead of being a set number of milliseconds, that number goes down every x number of milliseconds). The more obvious way would be to go ahead and create a function that manages that, but I’m having trouble actually making that. Please have a look at the code below:
local function generateRandomThings() local orange = display.newImageRect( mainGroup, "orange.png", 40, 40) orange.myName = "orange" table.insert(ballsTable,orange) physics.addBody(orange, {radius=20}) orange.x = math.random(display.screenOriginX + 20, \_W - 20) orange.y = -100 end
The above code generates the object at random places on the screen.
ballGenTimer = timer.performWithDelay(50,generateRandomThings,0)
This timer (local “ballGenTimer” is declared at the very top of my game.lua) is in my scene:show.
Thanks in advance!