@@ -9,16 +9,24 @@ var TimerEvent = new Class({
99 {
1010 /**
1111 * @property {number } delay - The delay in ms at which this TimerEvent fires.
12+ * @readOnly
1213 */
1314 this . delay = 0 ;
1415
1516 /**
16- * @property {number } repeatCount - If this TimerEvent repeats it will do so this many times.
17+ * @property {number } repeat - The total number of times this TimerEvent will repeat before finishing.
18+ * @readOnly
19+ */
20+ this . repeat = 0 ;
21+
22+ /**
23+ * @property {number } repeatCount - If repeating this contains the current repeat count.
1724 */
1825 this . repeatCount = 0 ;
1926
2027 /**
2128 * @property {boolean } loop - True if this TimerEvent loops, otherwise false.
29+ * @readOnly
2230 */
2331 this . loop = false ;
2432
@@ -56,7 +64,8 @@ var TimerEvent = new Class({
5664 {
5765 this . delay = GetFastValue ( config , 'delay' , 0 ) ;
5866
59- this . repeatCount = GetFastValue ( config , 'repeat' , 0 ) ;
67+ // Can also be set to -1 for an infinite loop (same as setting loop: true)
68+ this . repeat = GetFastValue ( config , 'repeat' , 0 ) ;
6069
6170 this . loop = GetFastValue ( config , 'loop' , false ) ;
6271
@@ -72,23 +81,40 @@ var TimerEvent = new Class({
7281
7382 this . paused = GetFastValue ( config , 'paused' , false ) ;
7483
75- // This works for setting an infinite repeat too
76- if ( this . repeatCount === - 1 )
77- {
78- this . loop = true ;
79- }
80-
8184 this . elapsed = 0 ;
8285 this . hasDispatched = false ;
86+ this . repeatCount = ( this . repeat === - 1 || this . loop ) ? 999999999999 : this . repeat ;
8387
8488 return this ;
8589 } ,
8690
91+ // Gets the progress of the current iteration, not factoring in repeats
8792 getProgress : function ( )
8893 {
8994 return ( this . elapsed / this . delay ) ;
9095 } ,
9196
97+ // Gets the progress of the timer overall, factoring in repeats.
98+ getOverallProgress : function ( )
99+ {
100+ if ( this . repeat > 0 )
101+ {
102+ var totalDuration = this . delay + ( this . delay * this . repeat ) ;
103+ var totalElapsed = this . elapsed + ( this . delay * ( this . repeat - this . repeatCount ) ) ;
104+
105+ return ( totalElapsed / totalDuration ) ;
106+ }
107+ else
108+ {
109+ return this . getProgress ( ) ;
110+ }
111+ } ,
112+
113+ getRepeatCount : function ( )
114+ {
115+ return this . repeatCount ;
116+ } ,
117+
92118 getElapsed : function ( )
93119 {
94120 return this . elapsed ;
0 commit comments