协程帧动画

 //负责移动的协程
    private IEnumerator MoveCoroutine(int newX,int newY,float time)
    {
        sweet.X = newX;
        sweet.Y = newY;
        //每一帧移动一点点
        Vector3 startPos = transform.position;
        Vector3 endPos=sweet.gameManager.CorrectPosition(newX, newY);

        for (float t = 0; t < time; t+=Time.deltaTime)
        {
            sweet.transform.position = Vector3.Lerp(startPos, endPos, t / time);
            yield return 0;
        }

        sweet.transform.position = endPos;
    }

猜你喜欢

转载自blog.csdn.net/wk6sae88/article/details/81502650