Hello. I’m building a 1942 type game and I’m having a problem with the timers.
function scene:enterScene( event ) startTimers() end function startTimers() firePlayerBulletTimer = timer.performWithDelay(2000, firePlayerBullet, -1) generateIslandTimer = timer.performWithDelay(5000, generateIsland, -1) end function firePlayerBullet() local tempBullet = display.newImage("bulletplayer.png", (player.x+playerWidth/2)-bulletWidth, player.y-bulletHeight) table.insert(playerBullets, tempBullet) planeGroup:insert(tempBullet) end function generateIsland() local tempIsland = display.newImage("island.png", math.random(0, display.contentWidth-islandWidth), -islandHeight) table.insert(islands, tempIsland) islandGroup:insert(tempIsland) print("Island generated") end
When the timer goes off, the firePlayerBullet() and generateIsland() functions get called twice as opposed to once and I’m not sure why it does that