mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-03 17:42:41 +08:00
Merge pull request #420 from pandamicro/master
More secured ActionManager / EventManager APIs in JSB
This commit is contained in:
+16
-6
@@ -141,18 +141,23 @@ function getSGTarget (target) {
|
||||
if (target instanceof cc.Component) {
|
||||
target = target.node._sgNode;
|
||||
}
|
||||
if (target instanceof cc.Node) {
|
||||
else if (target instanceof cc.Node) {
|
||||
target = target._sgNode;
|
||||
}
|
||||
else if (!(target instanceof _ccsg.Node)) {
|
||||
target = null;
|
||||
}
|
||||
return target;
|
||||
}
|
||||
var jsbAddAction = cc.ActionManager.prototype.addAction;
|
||||
cc.ActionManager.prototype.addAction = function (action, target, paused) {
|
||||
target = getSGTarget(target);
|
||||
jsbAddAction.call(this, action, target, paused);
|
||||
if (action._retained) {
|
||||
action.release();
|
||||
action._retained = false;
|
||||
if (target) {
|
||||
jsbAddAction.call(this, action, target, paused);
|
||||
if (action._retained) {
|
||||
action.release();
|
||||
action._retained = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -161,7 +166,12 @@ function actionMgrFuncReplacer (funcName, targetPos) {
|
||||
var oldFunc = proto[funcName];
|
||||
proto[funcName] = function () {
|
||||
arguments[targetPos] = getSGTarget(arguments[targetPos]);
|
||||
return oldFunc.apply(this, arguments);
|
||||
if (!arguments[targetPos]) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
return oldFunc.apply(this, arguments);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+10
-1
@@ -163,6 +163,9 @@ cc.eventManager.removeListeners = function (target, recursive) {
|
||||
if (target instanceof cc.Node) {
|
||||
target = target._sgNode;
|
||||
}
|
||||
else if (!(target instanceof _ccsg.Node)) {
|
||||
return;
|
||||
}
|
||||
this._removeListeners(target, recursive || false);
|
||||
};
|
||||
cc.eventManager._pauseTarget = cc.eventManager.pauseTarget;
|
||||
@@ -170,9 +173,12 @@ cc.eventManager.pauseTarget = function (target, recursive) {
|
||||
if (target instanceof cc.Component) {
|
||||
target = target.node._sgNode;
|
||||
}
|
||||
if (target instanceof cc.Node) {
|
||||
else if (target instanceof cc.Node) {
|
||||
target = target._sgNode;
|
||||
}
|
||||
else if (!(target instanceof _ccsg.Node)) {
|
||||
return;
|
||||
}
|
||||
this._pauseTarget(target, recursive || false);
|
||||
};
|
||||
cc.eventManager._resumeTarget = cc.eventManager.resumeTarget;
|
||||
@@ -183,6 +189,9 @@ cc.eventManager.resumeTarget = function (target, recursive) {
|
||||
if (target instanceof cc.Node) {
|
||||
target = target._sgNode;
|
||||
}
|
||||
else if (!(target instanceof _ccsg.Node)) {
|
||||
return;
|
||||
}
|
||||
this._resumeTarget(target, recursive || false);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user