@peach pellen
Still doesn’t show up.
for the terminal…
buttonfolder/level1.lua:76: attempt to compare nil with number
stack traceback:
[C]: ?
/buttonfolder/level1.lua:76: in function '\_listener'
Should the applied code go on top of the gameplay mechanic code or below? Like this?
[lua]x = -20
function game(object, event)
if(event.phase == “began”) then
if(checkForMatch == false and secondSelect == 0) then
–Flip over first button
buttonCover[object.number].isVisible = false;
lastButton = object
checkForMatch = true
elseif(checkForMatch == true) then
if(secondSelect ==0 and lastButton ~= object) then
–Flip over second button
buttonCover[object.number].isVisible = false;
secondSelect = 1;
–If buttons do not match, flip buttons over
if(lastButton.myName ~= object.myName) then
timer.performWithDelay(1250, function()
checkForMatch = false;
secondSelect = 0;
buttonCover[lastButton.number].isVisible = true;
buttonCover[object.number].isVisible = true;
end, 1)
–If buttons DO match, remove buttons
elseif(lastButton.myName == object.myName) then
timer.performWithDelay(1250, function()
checkForMatch = false;
secondSelect = 0;
lastButton:removeSelf();
object:removeSelf();
buttonCover[lastButton.number]:removeSelf();
buttonCover[object.number]:removeSelf();
end, 1)
end
end
end
end
end
local myTimer = function()
numSeconds = numSeconds - 1
counter.text = "Time: " … tostring( numSeconds )
print(numSeconds)
if numSeconds < 1 or button.numChildren <= 0 then
timer.cancel(timerInfo)
button:pause()
restartTimer = timer.performWithDelay( 300, function() callGameOver(); end, 1 )
end
end
local startTimer = function()
print(“Start Timer”)
timerInfo = timer.performWithDelay( 1000, myTimer, 0 )
end
local setScore = function( scoreNum )
local newScore = scoreNum
gameScore = newScore
if gameScore < 0 then gameScore = 0; end
scoreText.text = gameScore
scoreText.xScale = 0.5; scoreText.yScale = 0.5
scoreText.x = (480 - (scoreText.contentWidth * 0.5)) - 15
scoreText.y = 20
end
startTimer()[/lua]
Not sure how the code looks like on your end. So how it’s formatted might not look right. [import]uid: 128294 topic_id: 31211 reply_id: 124814[/import]