local screenWidth = display.contentWidth local screenHeight = display.contentHeight local circleScale = 75 local xPos = math.random(circleScale \* 1.5, screenWidth - circleScale \* 1.5) local yPos = math.random(100 + circleScale \* 1.5, screenHeight - circleScale \* 1.5) local Red = math.random(0, 255) local Green = math.random(0, 255) local Blue = math.random(0, 255) local timeLimit = 60 local timeLeft = display.newText(timeLimit, 160, 100, native.systemFontBold, 50) local score = 0 local scoreText = display.newText(score, 450, 100, native.systemFontBold, 50) local circle = display.newCircle( xPos, yPos, circleScale ) circle:setFillColor(Red, Green, Blue) function circleTouched(event) if (timeLimit ~= 0) then circle.x = math.random(circleScale \* 1.5, screenWidth - circleScale \* 1.5) circle.y = math.random(100 + circleScale \* 1.5, screenWidth - circleScale \* 1.5) circle:setFillColor(math.random(0, 255), math.random(0, 255), math.random(0, 255)) end end function countScore(event) score = score + 1 --native.showAlert("Score", score, { "OK\_Btn\_Text", "Dismiss\_Btn\_Text", listener }) scoreText.text = score end local function timerDown() timeLimit = timeLimit-1 timeLeft.text = timeLimit if(timeLimit==0)then timeLeft.text = "Times Up" end circle:addEventListener("tap", circleTouched) circle:addEventListener("tap", countScore) end timer.performWithDelay(1000,timerDown,timeLimit)