locking float precision

dbokserdbokser Member Posts: 8
edited November -1 in Working with GS (Mac)
Is there a way to specify how many decimal places I want a float to display? In my game, I'm keeping score with money. Whenever the character gets more money, I'm using an Interpolate to increment the money visually so it doesn't just pop into the new value. The problem arises that it starts to display 4 or 5 decimal places on the interpolation instead of the 2 that money has. I tried making the money an integer and then upon display dividing by 100.0 but it just converts the value back into a float and displays the 5 decimal places. Any suggestions on this?

Comments

  • firemaplegamesfiremaplegames Member Posts: 3,211
    I have a rolling score demo on my wall, but I made it before Interpolate came out. I'll try rebuilding it with Interpolate and see if that helps performance!

    As for your issue, are you able to simplify the money collected into pennies?

    So every time the player picks up something worth money,
    it adds to their totalPennies count?
    (or subtracts from it if they do something incorrectly)

    If so, it would be much easier to work with.

    And you could display it as dollars and cents like this:

    game.totalPennies = 2439

    Display Text
    "$"..floor(game.totalPennies/100).."."..game.totalPennies%100

    That would display as: $24.39

    Hope this helps!
    Joe
  • dbokserdbokser Member Posts: 8
    Sounds like a good solution. I'll try it out. Thanks!
Sign In or Register to comment.