Hello,
My game has rounds that accumulate points. After each round, I’d like to add the new points to the beginning score in an animated fashion much like a pinball table adds points as the ball strikes things.
I want the numbers to count up (or down) kind of in a blurr and then end on the final score.
I first just used performWithDelay and set the iteration value to the number of points to add or subtract.
local function incrementScore ( event )
totalScore = totalScore + sessionScore
totalScoreValue.text = totalScore
end
timer.performWithDelay(20, incrementScore, sessionScore )
The problem with this is that the sessionScore can range from hundreds to thousands. If I’m adding 2 thousand points, it takes too long.
I then did this
local function incrementScore ( event )
totalScore = totalScore + sessionScore/100
totalScoreValue.text = totalScore
end
timer.performWithDelay(20, incrementScore, 100 )
which gives a consistent overall time but the final value is sometimes off due to the fractions being added to the total score.
My current solution uses the above function in conjunction with a second performWithDelay that is tweaked to delay until just after the previous one finishes and it calls another function to set the totalScore to the final, correct, value. It’s a slimy hack and I need something better.
Anybody solve this one yet?
Thanks,
Tom
[import]uid: 81264 topic_id: 14887 reply_id: 314887[/import]
[import]uid: 3826 topic_id: 14887 reply_id: 54998[/import]