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

0 favourites
  • 7 posts
From the Asset Store
A set of vector game assets contains ground tiles and several objects, used for creating platformer games
  • 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?

  • [quote:3f0suz33]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.

  • Here is little demo showing you how to set property of textbox

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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...

  • 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 . 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?

  • 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

  • [quote:1zzxu78e]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

    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.

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