Think Bubble Class

It is my turn to post some useful code for everyone. I created a class that makes it very easy to visualize “think bubbles” containing text. Here is an example

I did all the calculations, so that the bubble is very easy to resize and position. I used this image to compute the ratios

 

The origin of the bubble is indicated by the red circle. 

Use the Text property to set text in the bubble. The class wll take care to fit the text into the text area by breaking the text into multiple lines. My calculation work for any font.

By using the FlipHorizontally method you can flip the bubble to the right or to the left.

You can get the class with the required texture file and additional assets here.

[UPDATE] I updated the class by adding some state transitions. When you call the method Show, the bubble fades in, persists for a few seconds and then fades out. NOTE: The bubble is fully transparent by default, so it is not visible unless you call the Show method. You can get the updated class here.

 

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*