so im working on the next level button of game. so if you pass it the button should show if not it says hidden, i get no erros, but the function doesn’t work, ill post the code below. Part two of the problem is when i set the levels to unlock next level it doesn’t work.
nextBtn = display.newText(“Next level”,0,0,“Helvetica”,15)
nextBtn.x=display.screenOriginX+200
nextBtn.y=display.contentHeight-5
nextBtn.isVisisble = false
nextBtn.destination = “play”
nextBtn:addEventListener(“tap”,buttonPress)
sceneGroup:insert(nextBtn)
local function showNext(condition)
if(condition == “pass”) then
nextBtn.isVisisble = true
levels[1] = 3
levels[2] = 1
elseif(condition == “passt”) then
nextBtn.isVisisble = true
levels[1] = 3
levels[2] = 1
elseif(condition == “fail”) then
nextBtn.isVisisble = false
end
end
local function gameOver(condition)
if(condition ==“Winner”) then
screenText.text=“Amazing!”;
elseif(condition ==“Not Bad”) then
screenText.text=“Not To Shabby.”
elseif (conditon ==“loser”) then
screenText.text=“You Can Do Better.”;
end
end
local function removeBalloons(obj)
obj:removeSelf();
balloons= balloons-1;
if(timeLeft ~= false) then
if(balloons == 0) then
timer.cancel(gameTimer);
gameOver(“Winner”)
showNext(“pass”)
elseif(balloons<= 30) then
gameOver(“Not Bad”);
showNext(“passt”)
elseif(balloons >= 31) then
gameOver(“loser”);
showNext(“fail”)
end
end
end
I’m still new so if i’m doing something very stupid please let me know lol
fixed the hide button, can’t figure out why level image wont change
nextBtn = display.newText(“Next level”,0,0,“Helvetica”,15)
nextBtn.x=display.screenOriginX+200
nextBtn.y=display.contentHeight-5
nextBtn.isVisisble = false
nextBtn.destination = “play”
nextBtn:addEventListener(“tap”,buttonPress)
sceneGroup:insert(nextBtn)
local function showNext(condition)
if(condition == “pass”) then
nextBtn.isVisisble = true
levels[1] = 3
levels[2] = 1
elseif(condition == “passt”) then
nextBtn.isVisisble = true
levels[1] = 3
levels[2] = 1
elseif(condition == “fail”) then
nextBtn.isVisisble = false
end
end
local function gameOver(condition)
if(condition ==“Winner”) then
screenText.text=“Amazing!”;
elseif(condition ==“Not Bad”) then
screenText.text=“Not To Shabby.”
elseif (conditon ==“loser”) then
screenText.text=“You Can Do Better.”;
end
end
local function removeBalloons(obj)
obj:removeSelf();
balloons= balloons-1;
if(timeLeft ~= false) then
if(balloons == 0) then
timer.cancel(gameTimer);
gameOver(“Winner”)
showNext(“pass”)
elseif(balloons<= 30) then
gameOver(“Not Bad”);
showNext(“passt”)
elseif(balloons >= 31) then
gameOver(“loser”);
showNext(“fail”)
end
end
end
I’m still new so if i’m doing something very stupid please let me know lol
fixed the hide button, can’t figure out why level image wont change