TextBox for displaying numbers?

Get help using Construct 2

Post » Thu Apr 04, 2013 7:58 pm

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?

B
9
S
4
G
1
Posts: 102
Reputation: 2,274

Post » Thu Apr 04, 2013 8:30 pm

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?
B
56
S
15
G
10
Posts: 910
Reputation: 11,972

Post » Thu Apr 04, 2013 11:09 pm

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.
B
9
S
4
G
1
Posts: 102
Reputation: 2,274

Post » Fri Apr 05, 2013 6:30 am

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...
B
49
S
11
G
10
Posts: 1,833
Reputation: 14,428

Post » Fri Apr 05, 2013 8:30 am

@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)
B
56
S
15
G
10
Posts: 910
Reputation: 11,972

Post » Fri Apr 05, 2013 8:47 am

@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.BluePhaze2013-04-05 08:49:07
B
49
S
11
G
10
Posts: 1,833
Reputation: 14,428

Post » Fri Apr 05, 2013 8:58 am

@BluePhaze, oh, right you are then. Didn't realise that was what you meant.
B
56
S
15
G
10
Posts: 910
Reputation: 11,972

Post » Fri Apr 05, 2013 9:28 pm

I got it BluePhaze TY too.
B
9
S
4
G
1
Posts: 102
Reputation: 2,274

Post » Fri Apr 05, 2013 11:37 pm

No problem, sorry if I went a little long on that one, I was half asleep so I tend to ramble a bit...BluePhaze2013-04-05 23:38:27
B
49
S
11
G
10
Posts: 1,833
Reputation: 14,428

Post » Thu Apr 25, 2013 4:03 am

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
B
51
S
7
G
1
Posts: 869
Reputation: 5,943

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 30 guests