how do you do a special animation for score ?

hi,

i would make this type of score :

the score is for example : 3400

next i win and my score become 3678

between the transition we can see 3456…and next 3537 untill 3678

it’s like the animation in “clash of clans” when the gold increase.

your help would be cool .

I wrote something like this recently, but it didn’t count up, it rotated each digit into position, but the idea of animating the score is the same.

I think you need to differentiate between the actual score and the displayed score, e.g. two variables rather than one, and when the displayed score is less than the actual score add one to it and redisplay it. You can do this on an enterFrame event (or other repeated timer event). You may want to have a short cut so if the gap is too big it goes up in bigger steps, depends on your game and how fast the score can go up.

you could also do it via transitions

local data = {score = 0} local scoreobj = display.newText( "" , 100 , 100 , native.systemFont , 24 ) Runtime:addEventListener( "enterFrame", function ()     scoreobj.text = math.round(data.score) -- you should optimisze this so it isnt't called unecasarily eveery frame end) transition.to(data,{score = 100, time = 1000})

Perhaps this tutorial will help you:

http://coronalabs.com/blog/2014/07/29/tutorial-incrementing-score-counter/

Rob

yes cool it’s what im looking for .

thanks everybody and specialy rob

I wrote something like this recently, but it didn’t count up, it rotated each digit into position, but the idea of animating the score is the same.

I think you need to differentiate between the actual score and the displayed score, e.g. two variables rather than one, and when the displayed score is less than the actual score add one to it and redisplay it. You can do this on an enterFrame event (or other repeated timer event). You may want to have a short cut so if the gap is too big it goes up in bigger steps, depends on your game and how fast the score can go up.

you could also do it via transitions

local data = {score = 0} local scoreobj = display.newText( "" , 100 , 100 , native.systemFont , 24 ) Runtime:addEventListener( "enterFrame", function ()     scoreobj.text = math.round(data.score) -- you should optimisze this so it isnt't called unecasarily eveery frame end) transition.to(data,{score = 100, time = 1000})

Perhaps this tutorial will help you:

http://coronalabs.com/blog/2014/07/29/tutorial-incrementing-score-counter/

Rob

yes cool it’s what im looking for .

thanks everybody and specialy rob