How do I align text in textbox at the right site?

Get help using Construct 2

Post » Wed Apr 02, 2014 1:00 pm

Hello everyone,

I`m using a textbox to display the score in my game. I`ve read that using textbox is more efficient than using the text-object, concerning the framerate. So here`s my question:

Is there any way to align the text, which is shown in the textbox, to the right side of the textbox? I want to show the score in the top right corner of the layout. When the score is increasing from 99 to 100, the additional third digit will leave the layout because it is always added to the right site of the number. Adding the additional digit to the left site would solve my problem. Any ideas? :)
B
21
S
9
G
2
Posts: 128
Reputation: 3,001

Post » Wed Apr 02, 2014 1:18 pm

I`m using a textbox to display the score in my game. I`ve read that using textbox is more efficient than using the text-object, concerning the framerate.


Where do you have this information from? I find it highly unlikely that you would experience any significant frame rate changes using one over the other. Unless you maybe use a serious amount of them, talking more than 500+ or something. I could imagine that the sprite font could cause some drop though.

But personally I wouldn't concern my self about this if I were you, there are other areas that would be far more important to optimize if you are concerned about FPS.

However you can change the alignment of the text in the properties. Cant remember what its called, but its somewhere in the bottom of the list, next to hotspot.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Post » Wed Apr 02, 2014 1:33 pm

Here is little demo showing you how to set property of textbox
You do not have the required permissions to view the files attached to this post.
B
257
S
43
G
15
Posts: 1,992
Reputation: 41,535

Post » Thu Apr 03, 2014 12:34 am

Thanks for the answers,

I got the information to not-use text object from here: https://www.scirra.com/tutorials/298/performance-tips-for-mobile-games It says: "NEVER use text object", which seemed logically to me. Sadly, I can`t find any possibility to adjust the alignement in the properties section, or find a tutorial where this is described (maybe I`m just to blind to find it).

The text-demo shows how to setup the text within the text-object to be aligned to the right, which is great, but not exactly what I need, see above...
B
21
S
9
G
2
Posts: 128
Reputation: 3,001

Post » Thu Apr 03, 2014 5:05 am

Ok I don't really know a lot about performance when it comes to mobile phones, as I don't work with those, so it might very well be true. However its written about 2 years ago so a lot of things might have changed and then again not :D. So probably need Ashley or someone that work with mobile apps to clarify it.

It seems that the textbox doesn't have an align feature, sorry for that, thought it did :(

But cant you just add a functionality so if content (Value) of score is higher than 99 you move the textbox X pixel to the left?
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Post » Thu Apr 03, 2014 5:26 am

Yes, I could actually shift the position of the text-box depending on the number of digits, haven`t thought about that. But I guess running an if-condition after every score increase won´t be helpful to increase the performance, either...

So the main question is: Does the text-object really drop the framerate or have these issues been fixed over the last two years? Maybe someone knows about that ;)
B
21
S
9
G
2
Posts: 128
Reputation: 3,001

Post » Thu Apr 03, 2014 5:35 am

Yes, I could actually shift the position of the text-box depending on the number of digits, haven`t thought about that. But I guess running an if-condition after every score increase won´t be helpful to increase the performance, either...


I wouldn't worry about that, that check would be made so fast that I would be very surprised if you would notice it and if you are really worried about it you can turn it off when the score is higher than 99. But you would need to make a SERIOUS amount of changes to score for it to impact your FPS. Otherwise the limitations of phones would have some really huge problems, making it near impossible to make any games I would assume :D

Secondly you can always add a text object and when you test you game, see if its does in fact make a different. And if it does, just replace it.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 30 guests