Score table and touch is not working in my game. Also It is not showing any error- Corona SDK version 3.0. Would you please help me to find an error
[lua]
–
– main.lua
–
local background = display.newImage(“clouds.jpg”)
background:scale(2, 2)
display.setStatusBar(display.HiddenStatusBar)
local physics = require(“physics”);
local physics = require(“physics”);
physics.setDrawMode(“normal”)
system.activate(“multitouch”);
_H = display.contentHeight;
_W = display.contentWidth;
balloons = 0;
numBalloons = 100;
startTime = 20;
totalTime = 20;
timeLeft = true;
playerReady = false;
Random = math.random;
local music = audio.loadStream(“music.mp3”);
local balloonPop = audio.loadSound(“balloonPop.mp3”);
local screenText = display.newText("…Loading Balloons…", 0, 0, native.systemFont, 16*2);
screenText.xScale = 2
screenText.yScale = 2;
screenText.anchorX = 0.5;
screenText.anchorY = 0.5
– Place the text on screen
screenText.x = _W / 2 - 210;
screenText.y = _H - 20;
local timeText = display.newText("Time: "…startTime, 0, 0, native.systemFont, 16*2);
timeText.xScale = 0.5;
timeText.yScale = 0.5;
timeText.anchorX = 0.5;
timeText.anchorY = 0.5;
timeText.x = _W / 2;
timeText.y = _H - 20;
physics.start()
physics.setGravity(0, -0.4)
local function startGame()
local myBalloon = display.newImageRect(“balloon.png”, 55, 55);
--myBalloon:setReferencePoint(display.CenterReferencePoint);
myBalloon.anchorX = 2;
myBalloon.anchorY = 2;
myBalloon.x = Random(50, _W-50);
myBalloon.y = (_H+10);
physics.addBody(myBalloon, “dynamic”, {density=0.1, friction=0.0, bounce=0.9, radius=10});
end
gameTimer = timer.performWithDelay(20, startGame, numBalloons);
local leftWall = display.newRect (0, 0, 1, display.contentHeight);
local rightWall = display.newRect (display.contentWidth, 0, 1, display.contentHeight);
local ceiling = display.newRect (0, 0, display.contentWidth, 1);
physics.addBody (leftWall, “static”, { bounce = 0.1 } );
physics.addBody (rightWall, “static”, { bounce = 0.1 } );
physics.addBody (ceiling, “static”, { bounce = 0.1 } );
local gameTimer;
– Did the player win or lose the game?
local function gameOver(condition)
– If the player pops all of the balloons they win
if (condition == “winner”) then
screenText.text = “Amazing!”;
– If the player pops 70 or more balloons they did okay
elseif (condition == “notbad”) then
screenText.text = “Not too shabby.”
– If the player pops less than 70 balloons they didn’t do so well
elseif (condition == “loser”) then
screenText.text = “You can do better.”;
end
end
– Remove balloons when touched and free up the memory they once used
local function removeBalloons(obj)
obj:removeSelf();
– Subtract a balloon for each pop
balloons = balloons - 1;
– If time isn’t up then play the game
if (timeLeft ~= false) then
– If all balloons were popped
if (balloons == 0) then
timer.cancel(gameTimer);
gameOver(“winner”)
elseif (balloons <= 30) then
gameOver(“notbad”);
elseif (balloons >=31) then
gameOver(“loser”);
end
end
end
local function countDown(e)
– When the game loads, the player is ready to play
if (startTime == totalTime) then
– Loop background music
audio.play(music, {loops =- 1});
playerReady = true;
screenText.text = “Hurry!”
end
– Subtract a second from start time
startTime = startTime - 1;
timeText.text = "Time: "…startTime;
– If remaining time is 0, then timeLeft is false
if (startTime == 0) then
timeLeft = false;
end
end
local myBalloon = display.newImage(“balloon.png”)
– Allow the user to touch the balloons
function touch(e)
– If time isn’t up then play the game
if (timeLeft ~= false) then
– If the player is ready to play, then allow the balloons to be popped
if (playerReady == true) then
if (e.phase == “ended”) then
– Play pop sound
audio.play(balloonPop);
– Remove the balloons from screen and memory
removeBalloons(self);
end
end
end
end
– Increment the balloons variable by 1 for each balloon created
balloons = balloons + 1;
– Add event listener to balloon
myBalloon:addEventListener(“touch”, myBalloon);
if (balloons == numBalloons) then
gameTimer = timer.performWithDelay(1000, countDown, totalTime);
else
– Make sure timer won’t start until all balloons are loaded
playerReady = false;
end
[/lua]