Hello Guest

Author Topic: Sprite Dimensions  (Read 3753 times)

m4ko

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 75
    • View Profile
Sprite Dimensions
« on: March 11, 2013, 03:14:11 pm »
Hello,

I have a problem regarding initial setup (i guess). I am using the tk2dCamera. When i insert a sprite and click on 1:1 in scaling it sets its scale to 270,270,270.

I guess that is not correct? At least I can't find out how to get the actual dimensions of a sprite (GetBounds) as the results are off. Sprite.width would be nice to have.

Camera settings:
http://imageshack.us/photo/my-images/713/camerau.png/

Sprite settings:
http://imageshack.us/photo/my-images/715/inspector.png/

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Sprite Dimensions
« Reply #1 on: March 11, 2013, 03:33:37 pm »
If your sprite isn't set up correctly for tk2dCamera, then the scale WILL increase significantly when displayed on there. If you configure the sprite collection to "Use tk2dCamera" then that will be correct.
GetBounds should be correct - it accounts for scale, but not transform.localScale. It is correct in my test case, but if you think its wrong, please send me a repro case for this - I would like to fix it.

width might be slightly meaningless, as your sprite could be rotated and or scaled by the transform, or localScale. Perhaps GetPoint( TopLeft,  BottomRight, etc ) returned as coordinates might be better?
If you want world space bounds, you can also use sprite.renderer.bounds.

m4ko

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 75
    • View Profile
Re: Sprite Dimensions
« Reply #2 on: March 11, 2013, 03:47:44 pm »
Thanks for the fast response. You were right. I forgot about the "use tk2d camera" setting. That is why my scale was off on the sprites. The GetBounds function now gives me perfectly fine sprite dimensions by using SPRITE.GetBounds().size.x.

Thank you very much.