@@ -47,6 +47,8 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{
4747 _elapsed :0 ,
4848 _firstTick :false ,
4949 _easeList : null ,
50+ _times :0 ,
51+ _speed :0.0 ,
5052
5153 /**
5254 * @constructor
@@ -55,6 +57,7 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{
5557 * var actionInterval = new cc.ActionInterval(3);
5658 */
5759 ctor :function ( d ) {
60+ this . _times = 0 ;
5861 cc . FiniteTimeAction . prototype . ctor . call ( this ) ;
5962 d !== undefined && this . initWithDuration ( d ) ;
6063 } ,
@@ -131,6 +134,19 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{
131134 var t = this . _elapsed / ( this . _duration > 0.0000001192092896 ? this . _duration : 0.0000001192092896 ) ;
132135 t = ( 1 > t ? t : 1 ) ;
133136 this . update ( t > 0 ? t : 0 ) ;
137+
138+ if ( this . _times > 1 && this . isDone ( ) ) {
139+ if ( ! this . _repeatForever ) {
140+ this . _times -- ;
141+ }
142+ //var diff = locInnerAction.getElapsed() - locInnerAction.getDuration();
143+ this . startWithTarget ( this . target ) ;
144+ // to prevent jerk. issue #390 ,1247
145+ //this._innerAction.step(0);
146+ //this._innerAction.step(diff);
147+ this . step ( this . getElapsed ( ) - this . getDuration ( ) ) ;
148+
149+ }
134150 } ,
135151
136152 /**
@@ -167,8 +183,6 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{
167183 return 0 ;
168184 } ,
169185
170- _speed :0.0 ,
171-
172186 /**
173187 * Changes the speed of an action, making it take longer (speed>1)
174188 * or less (speed<1) time. <br/>
@@ -194,6 +208,34 @@ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{
194208 */
195209 getSpeed : function ( speed ) {
196210 return this . _speed ;
211+ } ,
212+
213+ /**
214+ * Repeats an action a number of times.
215+ * To repeat an action forever use the CCRepeatForever action.
216+ * @param times
217+ * @returns {cc.ActionInterval }
218+ */
219+ repeat : function ( times ) {
220+
221+ times = parseInt ( times ) ;
222+ if ( isNaN ( parseInt ( times ) ) ) {
223+ this . _times = 0 ;
224+ } else {
225+ this . _times = times ;
226+ }
227+ return this ;
228+ } ,
229+
230+ /**
231+ * Repeats an action for ever. <br/>
232+ * To repeat the an action for a limited number of times use the Repeat action. <br/>
233+ * @returns {cc.ActionInterval }
234+ */
235+ repeatForever : function ( ) {
236+ this . _times = 2 ;
237+ this . _repeatForever = 1 ;
238+ return this ;
197239 }
198240} ) ;
199241
0 commit comments