using UnityEngine;
using System.Collections;
public class Animation : MonoBehaviour {
private Animator _animator;
[SerializeField]
private Vector2[] _Postion;
[SerializeField]
private float _framePerSecond;//帧速率
[SerializeField]
int _index = 0;
// Use this for initialization
void Awake () {
_animator = this.GetComponent<Animator>();
InvokeRepeating("onPotion", 1, 1/_framePerSecond);
Debug.Log(1 / _framePerSecond);
}
// Update is called once per frame
void onPotion() {
_animator.Play("aa");
gameObject.transform.localPosition = new Vector3(_Postion[_index].x, _Postion[_index].y, 0);
//Debug.Log("_index=" + _index + " " + _Postion[_index].x + " , " + _Postion[_index].y);
_index++;
if (_index == _Postion.Length) _index = 0;
}
}