Hello Guest

Author Topic: Get Texture & Rectangle from tk2dSpriteDefinition  (Read 4250 times)

mythgarr

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 8
    • View Profile
Get Texture & Rectangle from tk2dSpriteDefinition
« on: July 12, 2013, 10:32:36 pm »
I need to be able to get a reference to the Texture and Source Rectangle for a given sprite. I've poked around in the source code for a while now trying to figure out some way to do this without success. I understand that trimmed sprites would cause some trouble with this approach - if I disable trimming is there any way to get what I need?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Get Texture & Rectangle from tk2dSpriteDefinition
« Reply #1 on: July 13, 2013, 02:49:46 pm »
The source rectangle in the texture? Remember sprites can be rotated, and also flipped - also you  won't be able to use dicing, custom geometry, etc. if you want to do this.

You can find the 4 points / uvs for your sprite as described in SetClippedSpriteGeom. You can map UVs -> x & y by multiplying by texture width and height.