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

【酷熊科技】工作积累 ----------- 动画播放 直接写代码控制的

时间:2017-03-31 15:48:33      阅读:157      评论:0      收藏:0      [点我收藏+]

标签:called   float   get   obj   科技   ret   ons   logs   暂停   

 

动画 播放

 

 1 using UnityEngine;
 2 using System.Collections;
 3 
 4 public class GameLoading : MonoBehaviour {
 5 
 6     public bool isAnimate = true;                  // hero 是否播放动画  用于暂停游戏等
 7     public float animateFrameCountPerSecond = 0.1f;    // hero 每秒播放 图片 多少张
 8     public float timeAnimatePlay = 0.0f;           // hero 动画已经播放的时长
 9     public Sprite[] animatorFrames;                // hero 动画 播放的 图片 数组
10 
11 
12     // Use this for initialization
13     void Start () {
14     
15     }
16     
17     // Update is called once per frame
18     void Update ()
19     {
20         LoadingAnimate();
21     }
22 
23     private void LoadingAnimate()
24     {
25         if (!isAnimate)
26             return;
27 
28         timeAnimatePlay += Time.deltaTime;
29         int indexAnimate = (int) (timeAnimatePlay / (1.0f/(animateFrameCountPerSecond*animatorFrames.Length)));
30         
31         indexAnimate %= animatorFrames.Length;
32         gameObject.GetComponent<SpriteRenderer>().sprite = animatorFrames[indexAnimate];
33 
34     }
35 
36 }

 

【酷熊科技】工作积累 ----------- 动画播放 直接写代码控制的

标签:called   float   get   obj   科技   ret   ons   logs   暂停   

原文地址:http://www.cnblogs.com/dudu580231/p/6651451.html

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