I have a solution to the Experience Bar Width problem ;
- Create 2 variables
- Experience(Current Exp)
- MaxExperience(Amount of Exp needed to Level up)
- Create 2 sprites
- ExperienceBar(displays current Experience)
- MaxExperienceBar(Amount of Exp needed to Level up)
-
Then place the "ExperienceBar" sprite over top of the "MaxExperienceBar" sprite
- Then take the Experience Bar and set is width to "Experience" percent of the "MaxExperience" variable
ExperienceBar set width to: round(Experience/MaxExperience)*MaxExperienceBar.Width
This whole thing means that there is no direct correlation between the Experience Bar's width and the Variable "Experience". It actually just sets its width to a percentage.
ex. Player's Exp is 75/100, 100 being the amount of ex they need to level up.
Since 75/100 is 0.75, convert that to a percent and you get 75%, you then set the Exp Bar's width to 75% of its maximum width.
This Solution works with any type of bar ;
health, exp, ammo, timer, progress, etc.