Beispiel #1
0
 public void AnimPlay(List <Sprite> _list, bool _loop = false, int frame = 0)
 {
     ClearSequence();
     SequenceID        = 0;
     currentFrameIndex = 0;
     _list.ForEach(i => image_list.Add(i));
     image.sprite      = image_list[0];
     loop              = _loop;
     currentFrameIndex = frame;
     status            = anim_status.running;
 }
Beispiel #2
0
 public void AnimPlaySequence(List <List <Sprite> > _sequence)
 {
     ClearSequence();
     SequenceID        = 0;
     currentFrameIndex = 0;
     foreach (List <Sprite> _list in _sequence)
     {
         Sequence.Add(_list);
     }
     Sequence[0].ForEach(i => image_list.Add(i));
     image.sprite = image_list[0];
     loop         = true;
     status       = anim_status.running;
 }
Beispiel #3
0
    void Update()
    {
        if (status == anim_status.running)
        {
            //按帧率播放
            if (Time.frameCount % (30 / Framerate) == 0)
            {
                currentFrameIndex++;
            }

            //第一次播放结束
            if (currentFrameIndex >= image_list.Count)
            {
                SequenceRule();
                currentFrameIndex = 0;
                CircleEvent?.Invoke();
                onComplete?.Invoke();
                if (onComplete != null)
                {
                    onComplete = null;
                }
                Change_event?.Invoke();
                if (!loop && SequenceID == -1)
                {
                    status = anim_status.stop;
                    //停在最后一帧
                    currentFrameIndex = image_list.Count - 1;
                }
            }
            if (image_list.Count != 0)
            {
                image.sprite = image_list[currentFrameIndex];
            }
            else
            {
                Debug.LogError("动画序列帧为空!");
            }
        }
    }
Beispiel #4
0
 public void AnimStop()
 {
     status            = anim_status.stop;
     currentFrameIndex = 0;
     EndEvent?.Invoke();
 }
Beispiel #5
0
 public void AnimContinue()
 {
     status = anim_status.running;
 }
Beispiel #6
0
 public void AnimPause()
 {
     status = anim_status.pause;
 }
Beispiel #7
0
 public void ClearSequence()
 {
     status = anim_status.stop;
     image_list.Clear();
     Sequence.Clear();
 }