示例#1
0
文件: Enemy.cs 项目: fromek/Pear1
    public void Flip()
    {
        // Multiply the x component of localScale by -1.
        if (direction == GameHelper.CharacterDirection.Right)
            direction = GameHelper.CharacterDirection.Left;
        else
            direction = GameHelper.CharacterDirection.Right;

        Vector3 enemyScale = transform.localScale;
        enemyScale.x *= -1;
        transform.localScale = enemyScale;
        //if(isControlledByPlayer)
        //{
        GetComponent<RelativeJoint2D>().linearOffset = new Vector2(GetComponent<RelativeJoint2D>().linearOffset.x * -1, GetComponent<RelativeJoint2D>().linearOffset.y);
        //}
    }
示例#2
0
    void Flip()
    {
        facingRight = !facingRight;
        if (direction == GameHelper.CharacterDirection.Right)
            direction = GameHelper.CharacterDirection.Left;
        else
            direction = GameHelper.CharacterDirection.Right;

        Vector3 theScale = transform.localScale;
        theScale.x *= -1;
        transform.localScale = theScale;
        if (Monster != null)
        {
            //Monster.GetComponent<RelativeJoint2D>().linearOffset = new Vector2(Monster.GetComponent<RelativeJoint2D>().linearOffset.x *-1, Monster.GetComponent<RelativeJoint2D>().linearOffset.y);
            Monster.Flip();
        }
    }