@panc software
I appreciate your help on my game, but now unfortunately the code does not work at all within my “showMole function” Once i added the hitCount = 0 variable, the Corona runtime error did not appear but the code does nothing at all now. Here is what I have so far:
Here is my entire code if you kindly would take a better look at it, I am completely stummped!
local score -- Mole local moleGroup = display.newGroup() local moles = {} local lastMole = {} -- Sound local hit = audio.loadSound('hit.wav') -- Variables local timerSource local currentMoles = 0 local molesHit = 0 local timeLimit = 1000 local hitCount = 0 -- Functions local Main = {} local startButtonListeners = {} local showCredits = {} local hideCredits = {} local showGameView = {} local prepareMoles = {} local startTimer = {} local showMole = {} local popOut = {} local moleHit = {} 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 function prepareMoles() b1 = display.newImage('mole4.png', 12, 123) b1.type = "mole" b2 = display.newImage('mole1.png', 50, 32) b2.type = "mole" b3 = display.newImage('mole2.png', 360, 34) b3.type = "mole" b4 = display.newImage('mole3.png', 210, 7) b4.type = "mole" b5 = display.newImage('mole4.png', 193, 168) b5.type = "mole" b6 = display.newImage('mole5.png', 388, 126) b6.type = "mole" b7 = display.newImage('mole6.png', 302, 10) b7.type = "mole" b8 = display.newImage('mole.png', 200, 15) b8.type = "mole" b9 = display.newImage('mole.png', 200, 15) b9.type = "mole" moles = display.newGroup(b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11) for i = 1, 11 do moles[i]:addEventListener('tap', moleHit) moles[i].isVisible = false end startTimer() end function startTimer() timerSource = timer.performWithDelay(timeLimit, showMole, 0) end local moveObject = {} function showMole(e) lastMole.isVisible = false local randomHole = math.random(1, 11) lastMole = moles[randomHole] lastMole:setReferencePoint(display.BottomCenterReferencePoint) lastMole.yScale = 0.1 lastMole.isVisible = true if moveobj == isHit then hitCount = hitCount + 1 if hitCount == 5 then hitCount =0 timeLimit= timeLimit+500 end end Runtime:addEventListener('enterFrame', popOut) end function popOut(e) lastMole.yScale = lastMole.yScale + 0.2 if(lastMole.yScale \>=1) then Runtime:removeEventListener('enterFrame', popOut) end end function moleHit:tap(e) audio.play(hit) lastMole.isVisible = false local t = e.target if t.type == "mole" then molesHit = molesHit + 1 moleHit = display.newText('+1000', 380, 45, native.systemFontBold, 18) moleHit:setTextColor(255, 0, 0) transition.to( moleHit, { time=800, alpha=.01 } ) score.text = molesHit elseif t.type == "mole" then lifeIcons[lives].isVisible = false lives = lives - 1 end if( lives == 0) then alert() end end
That is my main coding for the game to function properly. I really appreciate your help on this project and can’t thank you enough! Keep coding and Merry Christmas !