Mobile.Flip C# (CSharp) Method

Flip() public method

public Flip ( ) : void
return void
    public virtual void Flip()
    {
        mobFacingRight = !mobFacingRight;
        Vector3 theScale = transform.localScale;
        theScale.x *= -1;
        transform.localScale = theScale;
        right = -right;
        StartDir = new Vector2(-(StartDir.x), StartDir.y);
        checkWall = new Ray2D(transform.position, StartDir);
    }

Usage Example

Example #1
0
        public void Move()
        {
            //If mobile is falling or its actions are locked, dont move
            if (IsFalling || Mobile.IsActionsLocked)
            {
                return;
            }

            //if user pressed left...
            if (InputHandler.IsCKDown(Keys.Left))
            {
                //and is facing right...
                if (Mobile.Facing == Facing.Right)
                {
                    Mobile.Flip();
                }

                //and move to the left
                if (IsAbleToMove)// && GameInformation.Instance.IsPlayerTurn)
                {
                    MoveSideways(Mobile.Facing);
                }
                else
                {
                    Mobile.ChangeFlipbookState(ActorFlipbookState.UnableToMove, true);
                    Mobile.PlayUnableToMoveSE();
                    return;
                }
            }
            //if the user pressed right...
            else if (InputHandler.IsCKDown(Keys.Right))
            {
                //and is facing left...
                if (Mobile.Facing == Facing.Left)
                {
                    Mobile.Flip();
                }

                if (IsAbleToMove)// && GameInformation.Instance.IsPlayerTurn)
                {
                    MoveSideways(Mobile.Facing);
                }
                else
                {
                    Mobile.ChangeFlipbookState(ActorFlipbookState.UnableToMove, true);
                    Mobile.PlayUnableToMoveSE();
                    return;
                }
            }
            else
            {
                IsMoving = false;
            }

            if ((InputHandler.IsCKUp(Keys.Left) && InputHandler.IsCKUp(Keys.Right)) || !IsAbleToMove)
            {
                Mobile.ChangeFlipbookState(ActorFlipbookState.Stand);
            }
        }
All Usage Examples Of Mobile::Flip