I have a code that is making something weird, that I don’t understand why.
I have a function to add points to a score
function addToScore(num) score = score + num settings.totalScore = score --every time we add a score, we save it to persistent storage settings:save() --scoreObject.text = score end
then when I “tap” on an object I call the funtion
sky = display.newImage ("colores/cielo.png") group:insert ( sky ) sky.x = display.contentWidth / 2 sky.y = display.contentHeight / 2 - 221 sky.name = "sky" local function skyListener (event) addToScore(10) print("azul") azulEspanol.isVisible = true azulEnglish.isVisible = true coinSky.isVisible = true transition.to(coinSky, {time=1000, x=glowCoin.x, y=glowCoin.y}) transition.to(azulEspanol, {time=100, delay=3000, x=-200}) audio.play(win) local function showColor () txAzul.isVisible = false txBlue.isVisible = false txRojo.isVisible = true txRed.isVisible = true carroRojo.isVisible = true transition.to(carroRojo, {time=200, x=600}) audio.play(horseSfx) imageScoreLabel:toFront() imageScoreObject:toFront() scoreObject:toFront() end transition.to(azulEnglish, {time=100, delay=3000, x=1200, onComplete=showColor}) return true end sky:addEventListener("tap", skyListener)
And it adds the 10 coins – but I don’t see it in my display object.
scoreObject = display.newText(tostring(score), 0, 0, native.systemFont, 30) group:insert(scoreObject) scoreObject.x = 620; scoreObject.y = 38
but when I relaunch the app, I see the points there.
tap – don’t see it
relaunch – now I have 20
tap – nothing
relaunch – now I see 30
can someone help me with this? please?
I supposed to see the change as soon as I tap the image.