Don’t know what it could possibly be… I tried everything I can with this code… and it just won’t work in the device.
The game consists of several questions, of which people have to choose an answer from the ones provided at the bottom of the screen. When you answer correctly, there’s a sliding out motion that takes away the last question and inserts the new one.
The problem here is, I call the ending screen with a delay of 1 minute and 20 seconds, but… it appears just about at the third question or even the second question, when not even 15 seconds have passed.
Then, when the minute 20 seconds pass, the ending screen appears again!
I really don’t know what may be causing that… but I’ll leave the code where you call the next questions here:
function nextQuestion() -- update screen var oldScreen = newScreen -- update question number index currQuestion = currQuestion+1 if currQuestion \> #playOrder then currQuestion = 1 end local questionNumber = playOrder[currQuestion] x=#content q2=math.random(1, x) q3=math.random(1, x) newScreen=display.newGroup() img1= display.newImageRect("Alumnos/sumasCD/source/images/pics/"..content[questionNumber].id..".png",250, 250, true) img1.x=400 img1.y=350 img2= display.newImageRect("Alumnos/sumasCD/source/images/pics/"..content[q2].id..".png",250, 250, true) img2.x=700 img2.y=350 if(difficulty==4)then img3=display.newImageRect("Alumnos/sumasCD/source/images/pics/"..content[q3].id..".png",250, 250, true) img3.x=800 img3.y=350 img1.x=250 img2.x=530 newScreen:insert(img3) end newScreen:insert(img1) newScreen:insert(img2) -- do transitions transitionIn(newScreen) transitionOut(oldScreen) -- make buttons letterButtons = {} local buttonColors = factory.getRandomColors(difficulty) -- determine upper or lower case isLowerCase = math.random(1,2) == 1 -- make letter button for correct letter total1=content[questionNumber].value total2=content[q2].value total=total1+total2 if(difficulty==4) then total3=content[q3].value total=total+total3 if(content[questionNumber].cat==1 and content[q2].cat==1 and content[q3].cat==1)then total=total..".00" end if(content[questionNumber].cat==2 or content[q2].cat==2 and content[q3].cat==2)then total=total.."0" end elseif(content[questionNumber].cat==1 and content[q2].cat==1)then total=total..".00" elseif(content[questionNumber].cat==2 or content[q2].cat==2 )then if(content[questionNumber].value==.5 and content[q2].value==.5) then total=total..".00" else total=total.."0" end end letter=total table.insert(letterButtons, factory.newLetterButton(letter, isLowerCase, buttonColors[1])) correctButton = letterButtons[1].graphics local buttonWidth = correctButton.width -- make other letter buttons local letters = factory.getRandomLetters(difficulty-1, letter) for i=1, difficulty-1 do table.insert(letterButtons, factory.newLetterButton(letters[i], isLowerCase, buttonColors[i+1])) end -- position letter buttons and add touch event listener local randomLetterOrder = factory.getRandomOrder(#letterButtons) local buttonSpacing = 260 local buttonsWidth = (#letterButtons \* buttonWidth) + ((#letterButtons-1) \* (buttonSpacing/4)) local buttonsX = centerX - (buttonsWidth/2) + 300 for i=1, #letterButtons do local button = letterButtons[i].graphics button.y = 600 button.x = buttonsX + (buttonSpacing \* (randomLetterOrder[i]-1)) button:addEventListener("touch", onLetterTouch) local randomDelay = transitionDuration + (math.random(1,10) \* 10) transition.from(button, {time = 500, delay = randomDelay, y = defaultHeight + button.height, transition=easing.easeOutElastic}) end -- play bubbles sound when letters animate in timer.performWithDelay(transitionDuration, playBubbles) end