TextWidth

0 favourites
  • 7 posts
  • I'm not sure whether it's a bug or not, but it's preventing me from doing something. Using the rev103.2.

    When a text is set to invisible, you can still access the text.Text, and it will show the correct string. However text.TextWidth will always show 0 regardless of the length of the string.

    And even after adding the event to make it visible before trying to use TextWidth, it still shows 0.

    Only way to use TextWidth is if the text is always visible.

  • Using r104 I can't reproduce the issue (neither in Firefox or Chrome)

    Here is a capx.

    The only issue I can find is that the textwidth returned is different in Firefox 15 (returns 215) than in Chrome 22 (returns 211).

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Well actually I tested it further after seeing your post, and it seems the text being visible or not isn't relevant. But when I try setting the width of the text to the TextWidth of the text, the value is 0.

    If instead of using textWidth to set the width I use a number, then it will display the correct value. But that defeats the purpose of textWidth.

    the capx

  • The text size can only be determined when the text is actually drawn. It might be difficult to change this because for example in the WebGL renderer, there is no way to measure the text at all until it really is drawn.

    Is this something you desperately need? It's currently by design. A possible workaround could be to have some text on-screen with opacity 0.

  • just thought i'd chime in with something relevant here..

    Ashley it can be a problem in other cases.. although the work around is simple.

    I had an event which created text and the clickable area behind it.

    In the same event I set the areas width to be the text.textwidth.. and obviously this didn't work because of what you just said.

    Anyway, the work around was just to add a "wait 0.00001" seconds just to make it set the width on the tick after the text was displayed.

  • I don't desperately need it, and like keepee said there are workarounds, like instead of using textwidth, you can multiply the textsize by the number of letters to set the width.

    I just thought textwidth was designed to avoid doing that.

    Don't worry about it, and keep up the great work.

    As a side note, I know you said you wouldn't add rotation to the particle system, but do you think adding animation to the particle is possible ?

    I know I could create my own particle system, but it just seems like a waste of energy when the existing particle system is great and only lacks animations

  • We don't have any plans to add to the Particles object. If you need more advanced functionality you can regularly spawn sprites with the bullet behavior and control the sprites individually, but it is slower than using Particles.

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