XP Bar / Leveling Up Example
Does anyone have a good XP Bar/ Leveling Up example? I have one that works in my iOS app, but it seems to be a bit unstable.
What mine does: XP Bar = Horizontal Counter; XP = global value
1. Growth of the XP bar
+XP Bar < XP
-Add 1 to XP Bar
2. Skipping Growth
+Continue Button is pressed
-Set XP Bar to XP
3. Skipping + Level Up
+Continue Button is pressed
+XP > MaxValue XP Bar
-Add 1 to Level (global value)
-Set XP to (XP-MaxValue XP Bar)
This works most of the time, but seems highly unreliable especially when skipping the level up action.
Does anyone have something similar to this that can detect when it's done, and can reliably auto-calculate leveling up and how much after the max value of a current level is reached goes into the next level?
For example:
XP to next level: 100
Player earns: 120
Therefore the next level gets 20/(xp to the next level) and a level up?
Thanks