码迷,mamicode.com
首页 > 其他好文 > 详细

减速

时间:2014-05-27 00:15:25      阅读:323      评论:0      收藏:0      [点我收藏+]

标签:style   c   class   blog   code   java   

bubuko.com,布布扣
using UnityEngine;
using System.Collections;

public class stopSpeed : MonoBehaviour {

    public bool canStop = false;
    public float scrollSpeed = 5.0f;

    // Use this for initialization
    void Start () {

    }
    
    // Update is called once per frame
    void Update () {
        if(canStop == true){
            canStop = false;
            StartCoroutine(StopScrolling(20.0f));
        }
    }

    IEnumerator StopScrolling (float time)
    {
        //Slow down to 0 in time
        var rate = 1.0f / time;
        var t = 0.0f;
        float startValue = scrollSpeed;

        while (t < 1.0f) 
        {
            t += Time.deltaTime * rate;
            scrollSpeed = Mathf.Lerp(startValue, 0, t);

            yield return new WaitForEndOfFrame();
        }
    }
}
bubuko.com,布布扣

 

减速,布布扣,bubuko.com

减速

标签:style   c   class   blog   code   java   

原文地址:http://www.cnblogs.com/softimagewht/p/3744985.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!