Hi you all, I’m using the score module that can be found @ http://coronalabs.com/blog/2013/12/10/tutorial-howtosavescores/. The first time I play the game (or for example I reload the project), it works great, but when I reload the scene the score starts increasing automatically.
Here’s the code I’ve used:
local scoreText = score.init({ fontSize = 20, font = "Fipps", x = display.contentCenterX, y = \_H/2-175, maxDigits = 1, leadingZeros = true, }) scoreText:setTextColor(1, 0.5, 0) local function move(event) if addScore.x \< \_W/2-100 then score.add(1) addScore.x = addScore.x + 100 end end Runtime:addEventListener( "enterFrame", move )
How can I fix that annoying issue? Thank you so much
Are you removing the enterFrame listener before you leave the scene?
Hi, thanks for your reply, anyway yes, I’m removing the enterFrame listener before leaving the scene using
local function replay() Runtime:removeEventListener( "enterFrame", move ) director:changeScene("jollyScene") end replayBTN:addEventListener("touch", replay)
but, when the app runs
local function move(event) if addScore.x \< \_W/2-100 then score.add(1) addScore.x = addScore.x + 100 end end Runtime:addEventListener( "enterFrame", move )
It adds the score of the last play.
For instance, if the first time I play the game I did 10 points, when I replay the game and I got the first point of THAT game, the score counter starts from 10, instead from 1.
Are you removing the enterFrame listener before you leave the scene?
Hi, thanks for your reply, anyway yes, I’m removing the enterFrame listener before leaving the scene using
local function replay() Runtime:removeEventListener( "enterFrame", move ) director:changeScene("jollyScene") end replayBTN:addEventListener("touch", replay)
but, when the app runs
local function move(event) if addScore.x \< \_W/2-100 then score.add(1) addScore.x = addScore.x + 100 end end Runtime:addEventListener( "enterFrame", move )
It adds the score of the last play.
For instance, if the first time I play the game I did 10 points, when I replay the game and I got the first point of THAT game, the score counter starts from 10, instead from 1.