View Full Version : speech bubbles
shellbryson
July 20th, 2007, 09:13 AM
I'm trying to figure out the best way to architect this;
We currently have an animated character on the site... calling a function makes her "speak"... as words appear her mouth changes shape. All this works. What I'd like to do is have the text appear in a dynamically sized speech bubble...
I was thinking of some mechanism to work out the length of the text she has been sent, then to size the bubble box around the text. But I'm sure it's not that simple. Has anyone done something similar or cares to share ideas?
S./
paularmstrong
July 20th, 2007, 09:31 AM
If you're using a monospace font, you could count the characters and size the objects accordingly.
shellbryson
July 20th, 2007, 09:40 AM
I'm trying to figure out the best way to architect this;
We currently have an animated character on the site... calling a function makes her "speak"... as words appear her mouth changes shape. All this works. What I'd like to do is have the text appear in a dynamically sized speech bubble...
I was thinking of some mechanism to work out the length of the text she has been sent, then to size the bubble box around the text. But I'm sure it's not that simple. Has anyone done something similar or cares to share ideas?
S./
Actually... I did it :)
1) created a text field, which the text is sent to one character at a time. This field is set to autosize.
2) create a second field which is hidden, but has the same font, font size etc as the first field. Also set to autosize, however the entire text is sent in one go to it.
3) First send the text to the hidden field. I can then read the .width of this field allowing me to size the visual speech bubble below the unhidden field
4) write the text one character at a time to the unhidden field.
Now I have a nice self-sizing speech bubble that I can call any time I want :)
fluid_tw0
July 20th, 2007, 09:52 AM
you can create textfield dynamically and use autosize to do that (changing bubble's size isn't a problem, is it?)
shellbryson
July 20th, 2007, 09:53 AM
If you're using a monospace font, you could count the characters and size the objects accordingly.
Yep that would work, but mono fonts look a bit nasty IMO... unless I can find an acceptable "natural" looking mono font anyway.
shellbryson
July 20th, 2007, 09:55 AM
you can create textfield dynamically and use autosize to do that (changing bubble's size isn't a problem, is it?)
The issue was that the text is being written to the text box one character at a time... and I didn't want the speech bubble wobbling all over the place as it was populated.
Using the hidden field did the trick, but I have to figure out what happens if two lots of speech are sent at once! I get totally trashed strings written to the text box... blah.
cesig
July 20th, 2007, 12:40 PM
It doesn't look like anyone's recommended textWidth or textHeight. Sometimes these are better than just width or height.
Also, what do you mean about two lots of text sent at once?
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.