2D Toolkit Forum

2D Toolkit => Support => Topic started by: duke22 on June 09, 2014, 04:00:51 am

Title: Get sprite region (in atlas)?
Post by: duke22 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).
Title: Re: Get sprite region (in atlas)?
Post by: unikronsoftware 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.