/// <summary> /// 在指定的图片上播放序列帧 /// </summary> /// <param name="image"></param> /// <param name="list"></param> public void AddAnimation(Image image, List <Sprite> list, int speed = 3, int flag = 1) { if (_animList == null) { _animList = new List <M_Animation>(); } if (list == null) { Debugger.LogError("List<Sprite> is null, please check!"); return; } M_Animation anim = new M_Animation(image, list, speed, flag); for (int i = 0; i < _animList.Count; ++i) { if (_animList[i].m_image == image) { if (_animList[i].m_spritList == list) { return; } _animList[i] = anim; return; } } image.sprite = list[0]; _animList.Add(anim); }
/// <summary> /// /移除制定的动画信息 /// </summary> /// <param name="image"></param> public void RemoveAnimation(Image image) { if (_animList == null) { return; } M_Animation anim = null; for (int i = 0; i < _animList.Count; ++i) { if (_animList[i].m_image != image) { continue; } anim = _animList[i]; break; } if (anim == null) { return; } _animList.Remove(anim); }
private void UpdatePreFrame() { if (_animList == null) { return; } for (int i = 0; i < _animList.Count; ++i) { M_Animation anim = _animList[i]; anim.PlayAnimation(); } }