Hello Guest

Author Topic: Sprites connecting seamlessly  (Read 5021 times)

spinner

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 13
    • View Profile
Sprites connecting seamlessly
« on: September 29, 2013, 12:39:21 pm »
Hello,

Imagine that I want to create a tiled bridge with a blue semi-transparent sprite.
Im using 40x40 sprites and Then I'm scaling x40.
What does the final size really means, is there a formula to know the current sprite size? How can I measure the size of a sprite in units so I know exatctly where I can position the next one?
Right now I'm adding the one with x+5, and it's almost correct (as attached), but there's a line between the sprites that I don't want to appear, I want them to connect seamsleesly.

And actually, the sprite itself seems to have a border that I didn't add (as you can see on the image as well). I created a plain blue semi-transparent and yet, after the commit to the atlas, it seems that the sprite collection created a border for it. So even if I add like x+4.95 (which I would prefer having more round values), the line will be there.

What am I doing wrong? Is there any trick or documentation that I need to read to understand how this work better?


unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Sprites connecting seamlessly
« Reply #1 on: September 29, 2013, 04:38:27 pm »
Have you set this up correctly?
http://unikronsoftware.com/2dtoolkit/forum/index.php/topic,294.0.html

The final size depends on how you set up the camera / sprite collection size.
If you set it up at 1 pixel per meter, then a 40x40 sprite will be exactly 40 units in size. At 10 pixels per meter, it'll be 4 units in size, etc.

spinner

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Sprites connecting seamlessly
« Reply #2 on: September 29, 2013, 05:07:05 pm »
And in the case I'm using a perspective camera? Is there a way to calculate that?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Sprites connecting seamlessly
« Reply #3 on: September 29, 2013, 05:10:24 pm »
offset it by sprite.GetBounds().size.x/y - that will be the size of the sprite.
Or use a tk2dTiledSprite instead.

spinner

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Sprites connecting seamlessly
« Reply #4 on: September 29, 2013, 05:11:41 pm »
Cool, thanks! Btw, the trick with the the Pad method worked and now I can use 5 units distance normally. :)