Hi,
I'd need to draw a comic-like speech bubble.
I thought of two different ways of doing so:
1) Using cut PNGs to draw it and fill the middle with white to show text into it.
or
2) Draw a rounded rectangle and some kind of small triangle to simulate one.
I'm a bit stuck between the two choices, which one in your opinion would be the best?
Keep in mind that it should wrap around the text. (I already did that for rectangle in-game notifications so the wrapping part will be easy).
Any other suggestions are welcome!
Thanks!
Speech bubble / Comic text balloon
Re: Speech bubble / Comic text balloon
Bumpidy bump! Any idea folks? Thanks
Re: Speech bubble / Comic text balloon
I'd probably use a Spritebatch, with a sprite containing the corners, sides and the arrow, and form speech bubbles in arbitrary size at run time for resolution independence. But it's probably not the easiest way to do it.
My game called Hat Cat and the Obvious Crimes Against the Fundamental Laws of Physics is out now!
Re: Speech bubble / Comic text balloon
Thanks! I'm not looking for an easy way but a working and reliable way of doing it. I'll check out the docs for the spritebatches.T-Bone wrote:I'd probably use a Spritebatch, with a sprite containing the corners, sides and the arrow, and form speech bubbles in arbitrary size at run time for resolution independence. But it's probably not the easiest way to do it.
-
- Party member
- Posts: 235
- Joined: Sat Dec 15, 2012 6:54 am
Re: Speech bubble / Comic text balloon
How detailed should this speech bubble be? Is it just an ellipse and a triangle, or are you wanting to be able to do cloud/thought bubbles? If it's the former, I'd go with your second option and just draw the shapes. To draw the ellipse/bubble part, just set its height to the height of all text lines combined + a margin. Set its width to the width of the widest text line + a margin. Then just draw a triangle for the "pointer."
For drawing ellipses in LOVE, see here (AFAIK LOVE does not currently have a built-in function for drawing ellipses): viewtopic.php?f=4&t=2687#p53692 Though everything I wrote above would actually be much easier in the current version of LOVE with a rectangle instead of an ellipse (as you probably already know, given that you already have rectangle text boxes of some form).
Note that all of that assumes that you will have speech bubbles of different sizes and that you want them to dynamically shape around text...if you don't, then the sprite method is much, much easier.
For drawing ellipses in LOVE, see here (AFAIK LOVE does not currently have a built-in function for drawing ellipses): viewtopic.php?f=4&t=2687#p53692 Though everything I wrote above would actually be much easier in the current version of LOVE with a rectangle instead of an ellipse (as you probably already know, given that you already have rectangle text boxes of some form).
Note that all of that assumes that you will have speech bubbles of different sizes and that you want them to dynamically shape around text...if you don't, then the sprite method is much, much easier.
Re: Speech bubble / Comic text balloon
I suggest the second approach: Draw everything with love's build-in drawing functions.
Second I suggest using a rectangular shaped speech bubble instead of an ellipse. Not only is it easier to implement, it is also much easier to determine the size of it. If you have a rectangular block of text, it is not easy to determine the radii of the ellipse and you will waste a lot of space on screen.
Second I suggest using a rectangular shaped speech bubble instead of an ellipse. Not only is it easier to implement, it is also much easier to determine the size of it. If you have a rectangular block of text, it is not easy to determine the radii of the ellipse and you will waste a lot of space on screen.
Check out my blog on gamedev
Re: Speech bubble / Comic text balloon
Thanks for your great responses, it really helped with the decision.
Okay, now I'll continue to draw everything with löve. But I have one last question. I drew this example bubble: (don't worry it'll be bigger in-game! haha) As you might notice, the corner are a tidy bit rounded, but that's about only 3 pixels per corner. So to properly draw this I would have to draw the rectangle and remove 3 pixels per corner? And then add the triangle, add the highlight and finally add the shadow. Am I right? Does that sound okay with you guys?
Thanks!
Okay, now I'll continue to draw everything with löve. But I have one last question. I drew this example bubble: (don't worry it'll be bigger in-game! haha) As you might notice, the corner are a tidy bit rounded, but that's about only 3 pixels per corner. So to properly draw this I would have to draw the rectangle and remove 3 pixels per corner? And then add the triangle, add the highlight and finally add the shadow. Am I right? Does that sound okay with you guys?
Thanks!
- ejmr
- Party member
- Posts: 302
- Joined: Fri Jun 01, 2012 7:45 am
- Location: South Carolina, U.S.A.
- Contact:
Re: Speech bubble / Comic text balloon
That sounds right. As the speech bubble becomes larger or smaller, depending on the text, it would probably look good to grow and shrink those corner elements appropriately, maybe using the optional scaling arguments for love.graphics.draw().tomshreds wrote: So to properly draw this I would have to draw the rectangle and remove 3 pixels per corner? And then add the triangle, add the highlight and finally add the shadow. Am I right?
Re: Speech bubble / Comic text balloon
You should check this snippet that draws rounded rectangle :
Code: Select all
function love.graphics.roundrect(mode, x, y, width, height, xround, yround)
local points = {}
local precision = (xround + yround) * .1
local invprec = 1/precision
local tI, hP = table.insert, .5*math.pi
if xround > width*.5 then xround = width*.5 end
if yround > height*.5 then yround = height*.5 end
local X1, Y1, X2, Y2 = x + xround, y + yround, x + width - xround, y + height - yround
local sin, cos = math.sin, math.cos
for i = 0, precision do
local a = (i*invprec-1)*hP
points[#points+1] = X2 + xround*cos(a)
points[#points+1] = Y1 + yround*sin(a)
end
for i = 0, precision do
local a = i*invprec*hP
points[#points+1] = X2 + xround*cos(a)
points[#points+1] = Y2 + yround*sin(a)
end
for i = 0, precision do
local a = (i*invprec+1)*hP
points[#points+1] = X1 + xround*cos(a)
points[#points+1] = Y2 + yround*sin(a)
end
for i = 0, precision do
local a = (i*invprec+2)*hP
points[#points+1] = X1 + xround*cos(a)
points[#points+1] = Y1 + yround*sin(a)
end
love.graphics.polygon(mode, unpack(points))
end
http://darky-ben.fr/Xut my webcomic (french)
Re: Speech bubble / Comic text balloon
Thanks dude! I'll try this =)Darky wrote:You should check this snippet that draws rounded rectangle :Code: Select all
function love.graphics.roundrect(mode, x, y, width, height, xround, yround) local points = {} local precision = (xround + yround) * .1 local invprec = 1/precision local tI, hP = table.insert, .5*math.pi if xround > width*.5 then xround = width*.5 end if yround > height*.5 then yround = height*.5 end local X1, Y1, X2, Y2 = x + xround, y + yround, x + width - xround, y + height - yround local sin, cos = math.sin, math.cos for i = 0, precision do local a = (i*invprec-1)*hP points[#points+1] = X2 + xround*cos(a) points[#points+1] = Y1 + yround*sin(a) end for i = 0, precision do local a = i*invprec*hP points[#points+1] = X2 + xround*cos(a) points[#points+1] = Y2 + yround*sin(a) end for i = 0, precision do local a = (i*invprec+1)*hP points[#points+1] = X1 + xround*cos(a) points[#points+1] = Y2 + yround*sin(a) end for i = 0, precision do local a = (i*invprec+2)*hP points[#points+1] = X1 + xround*cos(a) points[#points+1] = Y1 + yround*sin(a) end love.graphics.polygon(mode, unpack(points)) end
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 5 guests