Example #1
0
    //public float gameTimer = 300.0f;

    //public Text timerText;
    // Use this for initialization
    void Start()
    {
        body            = GetComponent <Rigidbody2D>();
        ani             = gameObject.GetComponent <Animator>();
        sr              = gameObject.GetComponent <SpriteRenderer>();
        directionFacing = AniDirection.RIGHT;
        //timerText.text = "";
    }
Example #2
0
 void Move()
 {
     ani.enabled = true;
     if (Input.GetKey(KeyCode.W))
     {
         body.transform.Translate(Vector2.up * 0.1f);
     }
     else if (Input.GetKey(KeyCode.A))
     {
         directionFacing = AniDirection.LEFT;
         ani.Play("New Animation"); body.transform.Translate(Vector2.left * 0.1f);
     }
     else if (Input.GetKey(KeyCode.D))
     {
         directionFacing = AniDirection.RIGHT;
         ani.Play("Right Walk"); body.transform.Translate(Vector2.right * 0.1f);
     }
     else
     {
         ani.enabled = false;
     }
 }
Example #3
0
 /// <summary>
 /// 设置朝向
 /// </summary>
 /// <param name="dir"></param>
 public void Turn(AniDirection dir)
 {
     m_sDirection = dir.ToString();
 }