Hello Guest

Author Topic: Using 2d tool kit to build a speechbubble...  (Read 14193 times)

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Using 2d tool kit to build a speechbubble...
« Reply #15 on: April 30, 2015, 07:39:55 pm »
It looks like your sprite isn't the same size as the text meshes - If you create the sprite of that bubble it needs to be the correct size, looks like it might be from a different collection / have different pixels per meter settings etc. You need to get the correct effect in the viewport first before your code will work.

codejoy

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: Using 2d tool kit to build a speechbubble...
« Reply #16 on: April 30, 2015, 09:12:09 pm »
ahhhh okay.  I did some tweaking turns out I double checked my font AND the sprite collection SETTINGS (I didn't realize I could set filter there too).  So it is crisper but still encompassing the text it grows on the borders.  I have a posted here a image with on top what its doing (with point filtering!) and on bottom something I did in gimp for what I am aiming for.


unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Using 2d tool kit to build a speechbubble...
« Reply #17 on: May 02, 2015, 06:33:37 pm »
Its the settings on the sliced sprite you need to modify. I think the borders are too small - you're scaling the borders rather than leaving them unscaled.

codejoy

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: Using 2d tool kit to build a speechbubble...
« Reply #18 on: May 06, 2015, 05:42:06 pm »
This seemed to work put the borders at 10.  Center middle anchored everything and wham takes any size text and grows around it and dose it well.

I attach the sliced sprite speech bubble as a child of my main player and it all works great, except when i walk the opposite direction.  To get the player sprite to face the other way i set his scale to -1 on the x. and it works, but the sliced sprite speech bubble now turns too and looks like text was in a mirror :(  not sure a way around this.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Using 2d tool kit to build a speechbubble...
« Reply #19 on: May 06, 2015, 10:14:48 pm »
Solution is not to attach the speech bubble, but in a script position it relative to the player.

codejoy

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: Using 2d tool kit to build a speechbubble...
« Reply #20 on: May 07, 2015, 03:45:35 am »
yep! :) thanks for all your help.  Going to have a script that tracks player just like the camera basically.

codejoy

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: Using 2d tool kit to build a speechbubble...
« Reply #21 on: May 11, 2015, 06:01:02 pm »
I had one more question as I used this more.  The bounds keeps resizing my sliced sprite larger and larger.  Here is my use case:

I have different lines of text goto the speech bubble.  It displays the line of text, then the next is sent to the speech bubble.  I *WAS* in the Start method sizing the bubble, but since its now part of my speaking code, it sizes itself when a new line of text comes in so I have  a function called SizeBubble on the sliced sprite:


Code: [Select]
public void SizeBubble()
{

if(!msh)
msh = transform.Find ("TextMesh").GetComponent<tk2dTextMesh>();

Debug.Log ("Mesh: "+ msh.text + " ****" );
Bounds b = msh.GetEstimatedMeshBoundsForString(msh.text);
spr=  GetComponent<tk2dSlicedSprite>();

spr.ReshapeBounds(b.min, b.max);
}

The start code looks like this:

Code: [Select]
void Start () {

msh = transform.Find ("TextMesh").GetComponent<tk2dTextMesh>();
if(!msh)
Debug.LogError ("Coulnd't get it!");

spr=  GetComponent<tk2dSlicedSprite>();
Bounds old = spr.GetBounds();

t=target.transform;

}

The thing I am seeing is that everytime i throw a new line of text at the bubble, even if the line is shorter than the last the sliced sprite grows and never shrinks.  Above you notice I try to save the bounds in a variable called old  which i called reshapbounds on in the SizeBubble on top (took it out as it did nothing) but I think I am not understanding how ReshapeBounds works as to why my sliced sprite keeps growing and never shrinks again to match a new line of text once my talky system sends it to the speechbubble.

So any pointers as to why the sliced sprite grows and never shrinks?


unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Using 2d tool kit to build a speechbubble...
« Reply #22 on: May 14, 2015, 11:30:12 pm »
I don't get it either. It should work. If you can't get it to work post a simple repro in private support and I'll take a look at it.