Hello Guest

Author Topic: Anchors and Flip  (Read 5434 times)

pdform

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 12
    • View Profile
    • The Balance Inc
Anchors and Flip
« on: February 05, 2013, 11:41:54 pm »
Hi,

I've noticed that if you flip a sprite on the editor, the sprite's anchor keeps working as expected, however, if you flip it on runtime, some crazy behavior occurs. For instance, I've set a center anchor, and called FlipX on a sprite. Since the anchor is in the center, I'd expect the sprite to be flipped around the center, so the anchor would still be at the center, however, I observe it changes to pos.x - sprite width / 2. Is it normal?

Thanks!

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Anchors and Flip
« Reply #1 on: February 05, 2013, 11:47:50 pm »
How have you set up the anchor?

pdform

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 12
    • View Profile
    • The Balance Inc
Re: Anchors and Flip
« Reply #2 on: February 05, 2013, 11:49:01 pm »
I've set it in the sprite collection, via editor. In my code I just call FlipX, I do not change the anchor anytime...

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Anchors and Flip
« Reply #3 on: February 05, 2013, 11:50:26 pm »
What platform are you testing this on? It only happens when you're running the game in the player right?

pdform

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 12
    • View Profile
    • The Balance Inc
Re: Anchors and Flip
« Reply #4 on: February 05, 2013, 11:54:21 pm »
I haven't actually tested the current game in any target platform, only on the player. However, I remember having the same problem with iOS and Android in the final build, for another game. In that situation I had to treat specifically the case when the sprite's scale was negative, i.e, the sprite was flipped, to reposition it to the correct coordinates (for the new anchor).

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Anchors and Flip
« Reply #5 on: February 06, 2013, 12:03:07 am »
I just tried this and I can't reproduce it. Can you send me a test case to support@unikronsoftware.com to look at it?

pdform

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 12
    • View Profile
    • The Balance Inc
Re: Anchors and Flip
« Reply #6 on: February 06, 2013, 12:04:59 am »
OK, I will. Thanks!