using UnityEngine;
public class Hero : MonoBehaviour {
public Sprite[] sprites;
public int frameCountPersconds = 10;
public float timer = 0;
private SpriteRenderer render;
private void Awake()
{
render = GetComponent<SpriteRenderer>();
}
void Update () {
timer += Time.deltaTime;
int frameIndex = (int)(timer / (1f / frameCountPersconds));
int frame = frameIndex % 2;
render.sprite = sprites[frame];
}
unity中随时间循环切换图片
猜你喜欢
转载自blog.csdn.net/qq_40323256/article/details/82155182
今日推荐
周排行