I have a result screen that shows bonus points and such. I want each text field to increment one after another and also have it increment by a certain amount each frame.
Result Screen pops up.
First is the player score
check the player score, is it more than the score we want to display
if the player score is greater than the player display score by 100
increase the player display score by 100
if the player score is greater than the player display score by 10
increase the player display score by 10
else increase the player display score by 1
when finished move to the next score…and so on.
I have thought of using timers to move from one score to the next, but not being in an Event.ENTER_FRAME it only does one if then moves to the next one. Also the if statement for incrementing the score looks ridiculous and I’m thinking there has to be a better way to do it. I was thinking of making it a separate function but then I wouldn’t know what to return, or how to return it so it looks like its increasing and not just showing the total number instantly.
If you have any questions please leave a comment. I’ll try to expand on it a little more.
You could make a new ScoreText class that inherits from TextField, and use that for each of your score text fields. On that class you could make a setTargetScore method that takes a score number, and handles the incrementation of the display number. Then it could dispatch an event when it is finished. You could listen for then events, and call the setTargetScore method on each ScoreText as you need to.
Another way, that is possibly better/easier, is to use TweenLite to tween your score number, and use its events to update the score textfield, and when its complete, move to the next one.
EDIT*
Here is an example of using Tweenlite to tween a score variable:
How to Tween A Variable with Flash and TweenLite
EDIT2*
Here is an example of my first method:
First here is the ScoreText class:
And here is the Main class: