Hello Guest

Author Topic: Update Size of Polygon Collider When Image Changes Size?  (Read 5232 times)

davedev

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 10
    • View Profile
Update Size of Polygon Collider When Image Changes Size?
« on: July 27, 2013, 05:59:13 pm »
I've reduced the size of my sprite images by 50% but the custom polygon colliders I have drawn don't adjust to the new size. They stay there old, 2x size. They look okay in the sprite editor, but in the world they are now 2x too big. Is there anyone to get them to all resize to the size of the new graphics?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Update Size of Polygon Collider When Image Changes Size?
« Reply #1 on: July 27, 2013, 06:31:45 pm »
If you've reduced your image sizes by 2x, surely the polygon in the editor won't be the correct size either? How have you resized the sprite images?

davedev

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Update Size of Polygon Collider When Image Changes Size?
« Reply #2 on: July 30, 2013, 10:46:04 am »
They look okay in the editor, but when I select them in the Scene view you can see that their size is 2x the new size and when the game is run the mouse hit detection responds to this 2x size. My solution was to go in and tweak each polygon collider slightly and commit which seems to fix it. However, it be nice to know where my procedure is wrong so I don't have to do the tweak.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Update Size of Polygon Collider When Image Changes Size?
« Reply #3 on: July 30, 2013, 12:40:41 pm »
When resizing the image, tk2d doesn't know what you're doing to the image, which is why it keeps the collider as is. Just selecting the sprite and committing will "fix" by trimming the collider to the texture bounds. You should probably redo the collider properly at the new size in this case.

The issue here is we don't know what you're doing to the image. Eg. if you were manually trimming out 0-alpha in your image, then nothing will need to be adjusted. Likewise, if you were adding content without scaling the original sprite, then you wouldn't necessarily want the collider resized either.