Exemplo n.º 1
0
 /// <summary>
 /// 停止播放动画
 /// </summary>
 public void StopDisplay()
 {
     if (isPlaying)
     {
         isPlaying = false;
         TimerUtils.Stop(this.GetHashCode().ToString());
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// 播放动画
 /// </summary>
 /// <param name="loop">是否循环播放</param>
 /// <returns></returns>
 public bool StartDisplay(bool loop)
 {
     isLoop     = loop;
     isFinished = false;
     isPlaying  = true;
     TimerUtils.Start(currentFrame.NextFrameInterval,
                      111, this.GetHashCode().ToString(), DisplayCallBack);
     return(true);
 }
Exemplo n.º 3
0
        private void DisplayCallBack(int n)
        {
            LinkedListNode <AnimationFrame> node = allAniFrames.Find(currentFrame).Next;

            if (node != null)
            {
                currentFrame = node.Value;
            }
            else if (isLoop)
            {
                currentFrame = allAniFrames.First.Value;
            }
            else
            {
                isFinished = true;
                TimerUtils.Stop(this.GetHashCode().ToString());
            }
        }
Exemplo n.º 4
0
			/// <summary>
			/// 启动计时器
			/// </summary>
			/// <param name="interval">计时器间隔</param>
			/// <param name="count">计时次数</param>
			/// <param name="func">回调函数</param>
			/// <returns>是否启动成功</returns>
			public bool Start(float interval, int count, TimerUtils.TimerCallBackHandle func)
			{
				if (count <= 0 || interval < 0 || func == null) return false;

				if (isRunning || isPaused)
				{
					return false;
				}
				else
				{
					isPaused = false;
					isExpired = false;
					isRunning = true;

					this.interval = interval;
					this.remain = this.interval;
					this.limitCount = count;
					this.currentCount = 0;

					this.callback = func;
				}

				return true;
			}