How do I make decimal point in a number always visible?

0 favourites
  • 4 posts
From the Asset Store
Connect the dots in the correct order and draw happy animals!
  • So, I have a global varibale with initial value of 100, every 0.1 sec, 0.1 is subtracted from the varible (making it a 0.1 sec countdown timer) and sprite font is updated so that it shows correct "time". So it shows something like:









    Id like it to show 99.0 too, how can I achieve it? I've tried to googleing it, also tried some *100, /100 variants, but with no avail. Any advice is apriciated!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • zeropad <img src="{SMILIES_PATH}/icon_e_wink.gif" alt=";)" title="Wink">

    OR you could use len(text)

    if yourTimeVariable = len(text) of 2 | setText to : yourTimeVariable & ".0"

    Which checks the length of the time and if it's = 2 (meaning 90 only 2 characters not 90.1) then you set the text to your time variable and the ".0"

  • Thanx, however, as far as I can tell, zeropad only ads digits ("0") in front of the number, and your other advice seems closer to what I'm looking for with need for some tweeking in case of single digit integers (or if I increase the variable to 1000) then in case of 3 digit integers.

    There must be some simpler solution, something like "float(Variable,2)" where 2 defines the number of decimal places

  • NP. Yeah I realized that on my first

    I would recommend the second method with some events to handle extra or single integers. I had to do something similar for my game timer.

    I assume you could use float in a text expression... but from my understanding C2 uses expression float(x) so I don't know if you could set decimal place so to speak. Would have to test to be certain.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)