博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
【酷熊科技】工作积累 ----------- 动画播放 直接写代码控制的
阅读量:6985 次
发布时间:2019-06-27

本文共 1078 字,大约阅读时间需要 3 分钟。

 

动画 播放

 

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 initialization13     void Start () {14     15     }16     17     // Update is called once per frame18     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
().sprite = animatorFrames[indexAnimate];33 34 }35 36 }

 

转载于:https://www.cnblogs.com/dudu580231/p/6651451.html

你可能感兴趣的文章
摄像机平滑更随脚本
查看>>
Struts2 标签配置详细
查看>>
需求管理工具比较 Doors_Requistie Pro_RDM
查看>>
centos+php+nginx的php.ini无法加载的问题
查看>>
从菜鸟到专家的五步编程语言学习法
查看>>
RequestQueue
查看>>
Android TextView 属性设置
查看>>
html元素分类以及嵌套规则
查看>>
android dpi
查看>>
C语言的预处理、编译、汇编、链接
查看>>
魅族 C++ 微服务框架技术内幕揭秘
查看>>
flask 学习笔记 mvc ,sqlalchemy(insert,update)
查看>>
HTML基础(一)
查看>>
EGOImageView 解析
查看>>
我的友情链接
查看>>
1.解读REST和JAX-RS
查看>>
将RHEL7/centos7系统网卡名称eno16777736改为eth0
查看>>
Nginx域名跳转
查看>>
NTP时间服务器安装
查看>>
Thinkphp3.23 关联模型relation方法不存在解决方法
查看>>