2D Toolkit Forum

2D Toolkit => Support => Topic started by: Copywright on March 05, 2013, 02:53:09 am

Title: Flipping sprites
Post by: Copywright 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.
Title: Re: Flipping sprites
Post by: unikronsoftware 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
Title: Re: Flipping sprites
Post by: Copywright 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?
Title: Re: Flipping sprites
Post by: unikronsoftware 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.