Hello Guest

Author Topic: Get sprite region (in atlas)?  (Read 4480 times)

duke22

  • Newbie
  • *
  • Posts: 1
    • View Profile
Get sprite region (in atlas)?
« on: June 09, 2014, 04:00:51 am »
I'm trying to grab the normalized (0-1) region within the atlas of a sprite so I can correctly map some custom geometry I have, but my sprite returns false for .extractRegion. Why is this? Is there a different way to get those atlas bounds?

edit: Also I obviously need to know the rotation (if its rotated).
« Last Edit: June 09, 2014, 11:32:44 am by duke22 »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Get sprite region (in atlas)?
« Reply #1 on: June 09, 2014, 12:50:22 pm »
.extractRegion is for sprites that were extracted from something else. If you want to grab the min and max extents and rotated states and use them in whatever way you want - look at tk2dSpriteGeomGen.SetClippedSpriteGeom, that works out the geometry and UVs for the different supported permutations. In addition to the sprite being rotated it could also be trimmed, i.e. the UVs will be smaller than the source UV rect.