TextBox for displaying numbers?

0 favourites
  • 10 posts
From the Asset Store
Forget about default textbox restrictions, you can create sprites atop of the textbox
  • So, my game have some abilities which cost a variable amount of gold.

    The price needs to be displayed on the buttons..

    I've done it with textboxes so far... But somehow it seems wrong.. Is there a smarter way?

  • Text boxes, or the text object? Text boxes are for receiving input, text object for displaying text/strings/variables/whatever.

    If you are using the text object, though, what seems wrong?

  • Well.. thought there might be an object only for numbers, using less memory.. But guess that would be pebbles anyway.

    Thanks... I will keep to the text objects.

  • Even if it is only for numbers it would have to convert them to a string to display them as text on the screen. So the text object is still where it's at :) Though you can look into doing sprite fonts and having a sprite for each character, then just drop them in an array and use them to represent the score...

  • BluePhaze, you don't need to convert number to a string to display in text boxes. Text boxes can display any content directly, including arrays, and numerical and even boolean variables (although it converts the latter to 0/1)

  • GeometriX I was explaining that if you want to display numbers, it is getting formatted as a string in order to be rendered as text on the screen. So there is no way to directly display numbers whithout using text/strings. The JavaScript/HTML is just doing it for you. You don't have to do anything specifically, that is how text is rendered. Basically there is no way to use less memory displaying the numbers as they always are rendered as a text string. In memory you can limit the amount of space used by numbers by casting them as an int, float, double, etc... but we don't get that level of granularity displaying the numbers on the users screen. It just gets converted to a string then rendered as text.

    I wasn't saying he has to do anything for this conversion to take place, I was stating that there is nothing you can do about it. IF you want to render numbers on the screen, they will be converted to a text string.

  • BluePhaze, oh, right you are then. Didn't realise that was what you meant.

  • I got it BluePhaze TY too.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • No problem, sorry if I went a little long on that one, I was half asleep so I tend to ramble a bit...

  • so my thought would be that using a text object (what i'm using) to display the value of a variable. I'm still trying to wrap my head around how C2 deals with data. I'm used to just sticking variables into where i want the information to be displayed, but it seems that C2 needs a little more configuring..

    what i'm doing is:

    1. creating a text object

    2. dragging that text object on the stage

    3. in properties / Text.. inserting the name of the Variable..

    what i woud like to see is the value appear in there and hopefully change in realtime as that global variable changes, but instead i just see the name of the variable. how else would it need to be done to see in real-time the value of a global in a text object?

    Thanks!

    Caleb

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