标签:style c class blog code java
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(); } } }
标签:style c class blog code java
原文地址:http://www.cnblogs.com/softimagewht/p/3744985.html