@@ -36,6 +36,7 @@ cc.HashElement = function () {
36
36
this . actionIndex = 0 ;
37
37
this . currentAction = null ; //CCAction
38
38
this . paused = false ;
39
+ this . lock = false ;
39
40
} ;
40
41
41
42
/**
@@ -84,6 +85,7 @@ cc.ActionManager = cc.Class.extend(/** @lends cc.ActionManager# */{
84
85
element . currentAction = null ;
85
86
element . paused = false ;
86
87
element . target = null ;
88
+ element . lock = false ;
87
89
this . _elementPool . push ( element ) ;
88
90
} ,
89
91
@@ -303,7 +305,7 @@ cc.ActionManager = cc.Class.extend(/** @lends cc.ActionManager# */{
303
305
304
306
_deleteHashElement :function ( element ) {
305
307
var ret = false ;
306
- if ( element ) {
308
+ if ( element && ! element . lock ) {
307
309
if ( this . _hashTargets [ element . target . __instanceId ] ) {
308
310
delete this . _hashTargets [ element . target . __instanceId ] ;
309
311
var targets = this . _arrayTargets ;
@@ -329,6 +331,7 @@ cc.ActionManager = cc.Class.extend(/** @lends cc.ActionManager# */{
329
331
this . _currentTarget = locTargets [ elt ] ;
330
332
locCurrTarget = this . _currentTarget ;
331
333
if ( ! locCurrTarget . paused && locCurrTarget . actions ) {
334
+ locCurrTarget . lock = true ;
332
335
// The 'actions' CCMutableArray may change while inside this loop.
333
336
for ( locCurrTarget . actionIndex = 0 ; locCurrTarget . actionIndex < locCurrTarget . actions . length ; locCurrTarget . actionIndex ++ ) {
334
337
locCurrTarget . currentAction = locCurrTarget . actions [ locCurrTarget . actionIndex ] ;
@@ -338,16 +341,16 @@ cc.ActionManager = cc.Class.extend(/** @lends cc.ActionManager# */{
338
341
//use for speed
339
342
locCurrTarget . currentAction . step ( dt * ( locCurrTarget . currentAction . _speedMethod ? locCurrTarget . currentAction . _speed : 1 ) ) ;
340
343
341
- if ( locCurrTarget . currentAction . isDone ( ) ) {
344
+ if ( locCurrTarget . currentAction && locCurrTarget . currentAction . isDone ( ) ) {
342
345
locCurrTarget . currentAction . stop ( ) ;
343
346
var action = locCurrTarget . currentAction ;
344
- // Make currentAction nil to prevent removeAction from salvaging it.
345
347
locCurrTarget . currentAction = null ;
346
348
this . removeAction ( action ) ;
347
349
}
348
350
349
351
locCurrTarget . currentAction = null ;
350
352
}
353
+ locCurrTarget . lock = false ;
351
354
}
352
355
// only delete currentTarget if no actions were scheduled during the cycle (issue #481)
353
356
if ( locCurrTarget . actions . length === 0 ) {
0 commit comments