Hello Guest

Author Topic: Flipping sprites  (Read 6282 times)

Copywright

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 33
    • View Profile
Flipping sprites
« on: March 05, 2013, 02:53:09 am »
Hey,

I'm sorry to bother with such a seemingly simple problem, but I'd like a quick solution. I just discovered the flipping function in tk2d, this whole time I've had animations for right and left. I fixed it, but I ran into a problem with FlipX:

Code: [Select]
public void PlayerAnimation()
    {
        playerAnimation.anim = playerSprite;
        playerAnimation.AnimationName = "Idle";

        if (playerMovement.physicalMoveDirection.x > 0)
       {
           playerAnimation.AnimationName = "Walk";
       }
        else
            if(playerMovement.physicalMoveDirection.x < 0)
            {
                playerAnimation.AnimationName = "Walk";
                playerBaseSprite.FlipX();
            }

        playerAnimation.AnimationPlayer();
    }

I'm just looking for FlipX to happen only once. Sorry if there's a really simple solution I'm just missing, I really appreciate the help. Thanks in advance.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Flipping sprites
« Reply #1 on: March 05, 2013, 09:40:22 pm »
Why don't you just set scale instead?
playerBaseSprite.scale = new Vector3( -1, 1, 1 ); // to flip horizontally
playerBaseSprite.scale = new Vector3(  1, 1, 1 ); // to display normally

Copywright

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 33
    • View Profile
Re: Flipping sprites
« Reply #2 on: March 05, 2013, 10:36:20 pm »
Yeah, I just started using that. The problem now is how choppy the animation is when moving left and right. Any way to fix this, or is this more an art asset problem?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Flipping sprites
« Reply #3 on: March 05, 2013, 10:49:39 pm »
It should be as smooth as your art is - most likely is its an art issue, but hard to say without looking at it.