Merge pull request #1812 from pandamicro/v1.5

Important Fix action manager issues
This commit is contained in:
Wang Nan
2017-07-26 10:08:18 +08:00
committed by GitHub
+14 -11
View File
@@ -29,15 +29,14 @@
* @constructor
* @private
*/
var HashElement = cc._Class.extend({
ctor:function () {
this.actions = [];
this.target = null; //ccobject
this.actionIndex = 0;
this.currentAction = null; //CCAction
this.paused = false;
}
});
var HashElement = function () {
this.actions = [];
this.target = null; //ccobject
this.actionIndex = 0;
this.currentAction = null; //CCAction
this.paused = false;
this.lock = false;
};
/**
* !#en
@@ -91,6 +90,8 @@ cc.ActionManager = cc._Class.extend(/** @lends cc.ActionManager# */{
element.actionIndex = 0;
element.currentAction = null;
element.paused = false;
element.target = null;
element.lock = false;
this._elementPool.push(element);
},
@@ -378,7 +379,7 @@ cc.ActionManager = cc._Class.extend(/** @lends cc.ActionManager# */{
_deleteHashElement:function (element) {
var ret = false;
if (element) {
if (element && !element.lock) {
if (this._hashTargets[element.target.__instanceId]) {
delete this._hashTargets[element.target.__instanceId];
var targets = this._arrayTargets;
@@ -407,6 +408,7 @@ cc.ActionManager = cc._Class.extend(/** @lends cc.ActionManager# */{
this._currentTarget = locTargets[elt];
locCurrTarget = this._currentTarget;
if (!locCurrTarget.paused && locCurrTarget.actions) {
locCurrTarget.lock = true;
// The 'actions' CCMutableArray may change while inside this loop.
for (locCurrTarget.actionIndex = 0; locCurrTarget.actionIndex < locCurrTarget.actions.length; locCurrTarget.actionIndex++) {
locCurrTarget.currentAction = locCurrTarget.actions[locCurrTarget.actionIndex];
@@ -416,7 +418,7 @@ cc.ActionManager = cc._Class.extend(/** @lends cc.ActionManager# */{
//use for speed
locCurrTarget.currentAction.step(dt * ( locCurrTarget.currentAction._speedMethod ? locCurrTarget.currentAction._speed : 1 ) );
if (locCurrTarget.currentAction.isDone()) {
if (locCurrTarget.currentAction && locCurrTarget.currentAction.isDone()) {
locCurrTarget.currentAction.stop();
var action = locCurrTarget.currentAction;
// Make currentAction nil to prevent removeAction from salvaging it.
@@ -426,6 +428,7 @@ cc.ActionManager = cc._Class.extend(/** @lends cc.ActionManager# */{
locCurrTarget.currentAction = null;
}
locCurrTarget.lock = false;
}
// only delete currentTarget if no actions were scheduled during the cycle (issue #481)
if (locCurrTarget.actions.length === 0) {