Hello Guest

Author Topic: Trimmed Space...to be used later?  (Read 5578 times)

pushxtonotdie

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 2
    • View Profile
Trimmed Space...to be used later?
« on: May 14, 2013, 11:25:28 pm »
Hi, we're evaluating using Tk2d for a certain project, and we were curious if you supported the ability to use the 'trimmed' space data at runtime to position the mesh. This feature, if I'm not mistaken exists in Cocos2d. Essentially what it does is:

trims the empty space away.
Records the delta of the trimmed space in the texture atlas.
Applies this delta to the mesh at runtime.

Does 2dtoolkit do this? If not, got a couple pointers on the best way to implement this?

Thanks!
C

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Trimmed Space...to be used later?
« Reply #1 on: May 14, 2013, 11:41:27 pm »
Yes it does.
You don't need to do anything to enable this, it is enabled by default.

pushxtonotdie

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Trimmed Space...to be used later?
« Reply #2 on: May 14, 2013, 11:50:50 pm »
Ah ha! Anchor should be upper left!  ::) That was our problem. Thanks for the quick reply!

MaaS

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 39
    • View Profile
Re: Trimmed Space...to be used later?
« Reply #3 on: May 16, 2013, 08:27:42 am »
I would love to see an option to apply that delta (sort of) to the gameobject world position.

IE: You have a warrior making a flying kick. Your anim could be the warrior performing the kick (crouching, jump, and kick while advancing a few units). First you import the whole anim to 2DTK, so all the empty space is trimmed. And if you use the same anchor for every sprite the mesh will move like in the anim, BUT... the gameobject position is static.

I tried to add a second anchor to 2DTK sprites, for gameobject delta, using your anchor code, but it seems that the delta is added to the trimmed mesh vertices, so I cant use it later for reposition while displaying a frame... And didnt want to change the sprite collection data :S

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Trimmed Space...to be used later?
« Reply #4 on: May 16, 2013, 09:42:04 am »
That won't be possible the way things are set up - the animation script is on the gameobject itself, so if it moved itself, it wouldn't know where it stands relatively - its easy to accumulate errors and start drifting like this. Also, if you had a rigidbody/character controller you'd have to move things in a special way - making it very impractical.

But... this is one of those things the multiple anchor feature could be useful for - create an anchor for the "position" and then use that to do what you need to.