Merge pull request #203 from pandamicro/v0.7

Made Action independent from retain release
This commit is contained in:
pandamicro
2016-01-07 22:51:28 +08:00
2 changed files with 111 additions and 0 deletions
+4
View File
@@ -869,6 +869,7 @@ var Node = cc.Class({
onTouchMoved: _touchMoveHandler,
onTouchEnded: _touchEndHandler
});
this._touchListener.retain();
cc.eventManager.addListener(this._touchListener, this);
}
}
@@ -884,6 +885,7 @@ var Node = cc.Class({
onMouseUp: _mouseUpHandler,
onMouseScroll: _mouseWheelHandler,
});
this._mouseListener.retain();
cc.eventManager.addListener(this._mouseListener, this);
}
}
@@ -917,6 +919,7 @@ var Node = cc.Class({
}
cc.eventManager.removeListener(this._touchListener);
this._touchListener.release();
this._touchListener = null;
}
},
@@ -929,6 +932,7 @@ var Node = cc.Class({
}
cc.eventManager.removeListener(this._mouseListener);
this._mouseListener.release();
this._mouseListener = null;
}
},
+107
View File
@@ -78,6 +78,113 @@ cc.Scheduler.prototype.unschedule = function (callback, target) {
this._unschedule(target, callback);
};
// Independent Action from retain/release
var actionArr = [
cc.ActionEase,
cc.EaseExponentialIn,
cc.EaseExponentialOut,
cc.EaseExponentialInOut,
cc.EaseSineIn,
cc.EaseSineOut,
cc.EaseSineInOut,
cc.EaseBounce,
cc.EaseBounceIn,
cc.EaseBounceOut,
cc.EaseBounceInOut,
cc.EaseBackIn,
cc.EaseBackOut,
cc.EaseBackInOut,
cc.EaseRateAction,
cc.EaseIn,
cc.EaseElastic,
cc.EaseElasticIn,
cc.EaseElasticOut,
cc.EaseElasticInOut,
cc.RemoveSelf,
cc.FlipX,
cc.FlipY,
cc.Place,
cc.CallFunc,
cc.DelayTime,
cc.Sequence,
cc.Spawn,
cc.Speed,
cc.Repeat,
cc.RepeatForever,
cc.Follow,
cc.TargetedAction,
cc.Animate,
cc.OrbitCamera,
cc.GridAction,
cc.ProgressTo,
cc.ProgressFromTo,
cc.ActionInterval,
cc.RotateTo,
cc.RotateBy,
cc.MoveBy,
cc.MoveTo,
cc.SkewTo,
cc.SkewBy,
cc.JumpTo,
cc.JumpBy,
cc.ScaleTo,
cc.ScaleBy,
cc.Blink,
cc.FadeTo,
cc.FadeIn,
cc.FadeOut,
cc.TintTo,
cc.TintBy,
];
function getCtorReplacer (proto) {
var ctor = proto._ctor;
return function () {
ctor.apply(this, arguments);
this.retain();
this._retained = true;
};
}
for (var i = 0; i < actionArr.length; ++i) {
var proto = actionArr[i].prototype;
proto._ctor = getCtorReplacer(proto);
}
function setChainFuncReplacer (proto, name) {
var oldFunc = proto[name];
proto[name] = function () {
if (this._retained) {
this.release();
this._retained = false;
}
var newAction = oldFunc.apply(this, arguments);
newAction.retain();
newAction._retained = true;
};
}
setChainFuncReplacer(cc.ActionInterval.prototype, 'repeat');
setChainFuncReplacer(cc.ActionInterval.prototype, 'repeatForever');
setChainFuncReplacer(cc.ActionInterval.prototype, 'easing');
var jsbRunAction = cc.Node.prototype.runAction;
cc.Node.prototype.runAction = function (action) {
if (action._retained) {
action.release();
action._retained = false;
}
jsbRunAction.call(this, action);
};
var jsbAddAction = cc.ActionManager.prototype.addAction;
cc.ActionManager.prototype.addAction = function (action, target, paused) {
if (action._retained) {
action.release();
action._retained = false;
}
jsbAddAction.call(this, action, target, paused);
};
// ccsg
window._ccsg = {
Node: cc.Node,