开启结束协程
StartCoroutine(moveCor); //开启名为moveCor的协程 StopCoroutine(moveCor); //关闭名为moveCor的协程
###写法
`
private IEnumerator MoveCor(int newx,int newy,float time)
{
//每一帧移动一点点
Vector3 start = transform.position;
Vector3 end = sweet.game_manage.correct(newx, newy);
for(float t=0;t<time;t+=Time.deltaTime) //Time.deltaTime表示每一帧的时间
{
sweet.transform.position = Vector3.Lerp(start, end, t / time);
yield return 0; //表示每一帧都有返回
}
sweet.transform.position = end; //防止协程结束还没移动到位置,直接强制到end,在
}`