Okay this time I am sure everything is correct but the “1” does not update with the waveTable since it just stays at “1”, would you mind taking a look at the whole code, thank you.
----------------------------------------------------------------------------------------- -- -- main.lua -- ----------------------------------------------------------------------------------------- -- Hide Status Bar display.setStatusBar(display.HiddenStatusBar) -- Background local bg = display.newImage('gameBg.png') local icon = display.newImage('lifeicon1.png', 3, 3) local icon2 = display.newImage('lifeicon2.png', 352, 3) -- Title View local titleBg local playBtn local creditsBtn local titleView -- Credits View local creditsView -- Score local score -- hare local hareGroup = display.newGroup() local hares = {} local lasthare = {} -- Sound local hit = audio.loadSound('hit.wav') local wave = 1 local waveText local waveTable = {1, 2, 3, 4} local wavehares = 0 -- Variables local currenthares = 0 local haresHit = 0 local timerSource local timeToNexthare = 1000 -- Functions local Main = {} local startButtonListeners = {} local showCredits = {} local hideCredits = {} local showGameView = {} local preparehares = {} local startTimer = {} local showhare = {} local popOut = {} local hareHit = {} local alert = {} local lifeIcons = {} local lives = 3 local maxLives = 3 local i for i = 1, maxLives do lifeIcons[i] = display.newImage("lifeicon.png") lifeIcons[i].x = 57 + (lifeIcons[i].contentWidth \* (i - 1)) lifeIcons[i].y = 23 end local haresPositions = { {'hare4.png', 12, 123, "hare"}, {'hare1.png', 50, 32, "hare"}, {'hare2.png', 360, 34, "hare"}, {'hare3.png', 210, 7, "hare"}, {'hare4.png', 193, 168, "hare"}, {'hare5.png', 388, 126, "hare"}, {'hare6.png', 302, 10, "hare"}, {'hare.png', 200, 15, "hare"}, {'hare.png', 200, 15, "hare"}, {'obama1.png', 50, 32, "hare"}, {'obama2.png', 360, 34, "hare"}, } function hareHit:tap(e) audio.play(hit) lasthare.isVisible = false local t = e.target if t.type == "hare" then haresHit = haresHit + 1 hareHit = display.newText('+1000', 380, 45, native.systemFontBold, 18) hareHit:setTextColor(255, 0, 0) transition.to( hareHit, { time=800, alpha=.01 } ) score.text = haresHit elseif t.type == "obama" then lifeIcons[lives].isVisible = false lives = lives - 1 if( lives == 0) then alert() end end end local function preparehares() hares = display.newGroup() for i = 1, #haresPositions do local hare = display.newImage(haresPositions[i][1],haresPositions[i][2],haresPositions[i][3]) hare.type = haresPositions[i][4] hare:addEventListener('tap', hareHit) hare.isVisible = false hares:insert(hare) end startTimer() end function popOut(e) lasthare.yScale = lasthare.yScale + 0.2 if(lasthare.yScale \>=1) then Runtime:removeEventListener('enterFrame', popOut) end end local function showhare() lasthare.isVisible = false local randomHole = math.floor(math.random() \* 11) + 1 lasthare = hares[randomHole] lasthare:setReferencePoint(display.BottomCenterReferencePoint) lasthare.yScale = 0.1 lasthare.isVisible = true transition.to(lasthare, { time=300, yScale=1 }) end function startTimer() if wavehares == waveTable[wave] then wave = wave + 1 waveText.text = tostring(wave) wavehares = 0 timerSource = timer.performWithDelay(timeToNextWave, startTimer) return end timerSource = timer.performWithDelay(timeToNexthare, startTimer) showhare() timeToNexthare = math.max(timeToNexthare - 30, 600) end function alert() timer.cancel(timerSource) lasthare.isVisible = false local alert = display.newImage('alertBg.png') alert:setReferencePoint(display.CenterReferencePoint) alert.x = display.contentCenterX alert.y = display.contentCenterY transition.from(alert, {time = 300, xScale = 0.3, yScale = 0.3}) local score = display.newText(haresHit, 220, 190, native.systemFontBold, 18) score:setTextColor(204, 152, 102) end -- Main Function function Main() titleBg = display.newImage('titleBg.png') playBtn = display.newImage('playBtn.png', display.contentCenterX + 135.5, display.contentCenterY + 20) creditsBtn = display.newImage('creditsBtn.png', display.contentCenterX - 190.5, display.contentCenterY + 20) titleView = display.newGroup(titleBg, playBtn, creditsBtn) startButtonListeners('add') end function startButtonListeners(action) if(action == 'add') then playBtn:addEventListener('tap', showGameView) creditsBtn:addEventListener('tap', showCredits) else playBtn:removeEventListener('tap', showGameView) creditsBtn:removeEventListener('tap', showCredits) end end function showCredits:tap(e) playBtn.isVisible = false creditsBtn.isVisible = false creditsView = display.newImage('creditsView.png') transition.from(creditsView, {time = 300, x = -creditsView.width, onComplete = function() creditsView:addEventListener('tap', hideCredits) creditsView.x = creditsView.x - 0.5 end}) end function hideCredits:tap(e) playBtn.isVisible = true creditsBtn.isVisible = true transition.to(creditsView, {time = 300, x = -creditsView.width, onComplete = function() creditsView:removeEventListener('tap', hideCredits) display.remove(creditsView) creditsView = nil end}) end function showGameView:tap(e) transition.to(titleView, {time = 300, x = -titleView.height, onComplete = function() startButtonListeners('rmv') display.remove(titleView) titleView = nil end}) score = display.newText('0' , 397, 9, native.systemFontBold, 25) score:setTextColor(255, 200, 0) waveText = display.newText(tostring(wave), 300, 5, native.systemFontBold, 25) waveText:setTextColor(255, 200, 0) preparehares() end Main ()