Hello Guest

Author Topic: Clipping a sprite by it's full (not trimmed) size?  (Read 5785 times)

Zama Games

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 13
    • View Profile
Clipping a sprite by it's full (not trimmed) size?
« on: April 28, 2013, 01:29:02 pm »
Hi, I have a set of sprites some of which aren't perfectly centered inside the image (and this must be that way). I am trying to use tk2dClippedSprite to cut the sprite into 4 parts but unfortunately the clipping coords are applied to the trimmed sprite and not the whole sprite.

E.g. here is the initial sprite which I want to cut into 4 equal parts (see "initial_spr.png")


So, I create 4 ClippedSprite's with the following clipping coords:
( (0, 0), (0.5, 0.5) )
( (0.5, 0), (1, 0.5) )
( (0, 0.5), (0.5, 1) )
( (0.5, 0.5), (1, 1) )

and expect to get this (see "req_cuts.png")


But I get this (see "clipped_cuts.png")


Is it at all possible to get what I need with the provided ClippedSprite class?
Any other solution?
Thanks!
« Last Edit: April 28, 2013, 04:33:04 pm by Zama Games »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Clipping a sprite by it's full (not trimmed) size?
« Reply #1 on: April 28, 2013, 06:09:32 pm »
That looks like a bug. I'll look into it.
For now, a temporary fix could be disabling trimming on that sprite alone.
« Last Edit: April 28, 2013, 06:11:13 pm by unikronsoftware »

Zama Games

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Clipping a sprite by it's full (not trimmed) size?
« Reply #2 on: April 28, 2013, 06:22:55 pm »
Thanks, hm, unfortunately i can't disable trimming since the sprites are very large and with trimming disabled the atlases which I'd have to generate to fit everything in will exceed 50MB or even 100MB.
Please let me know when you would be able to publish a fix. I guess I'd have to delay publishing of the game for now until there is a fix and start working on another one I have in the plan.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Clipping a sprite by it's full (not trimmed) size?
« Reply #3 on: April 29, 2013, 12:15:05 am »
I've got a fix for this now. It wasn't as bad as I thought it'd be.
Drop me an email at support and I'll send you a patch.

Zama Games

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Clipping a sprite by it's full (not trimmed) size?
« Reply #4 on: April 29, 2013, 08:03:16 am »
Amazing :) Thanks for the fast reply and fix :)