TextWidth

Bugs will be moved here once resolved.

Post » Thu Sep 27, 2012 4:02 pm

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.Kaisirak2012-09-27 16:25:01
B
5
S
1
G
1
Posts: 39
Reputation: 1,128

Post » Thu Sep 27, 2012 5:09 pm

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).
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,999
Reputation: 57,793

Post » Thu Sep 27, 2012 6:15 pm

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
B
5
S
1
G
1
Posts: 39
Reputation: 1,128

Post » Mon Oct 01, 2012 2:31 pm

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.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Mon Oct 01, 2012 10:35 pm

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.
B
28
S
8
G
1
Posts: 469
Reputation: 4,683

Post » Tue Oct 02, 2012 12:45 am

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
B
5
S
1
G
1
Posts: 39
Reputation: 1,128

Post » Tue Oct 02, 2012 10:59 am

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.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544


Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 1 guest