From 2d98b903c59558c0e22972a2db124ac4018c79a4 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Mon, 24 Apr 2017 15:59:57 +0800 Subject: [PATCH 1/2] Add pauseAllActions and resumeAllActions for cc.Node --- cocos2d/core/CCNode.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/cocos2d/core/CCNode.js b/cocos2d/core/CCNode.js index 8f5c725e68..1be0e34381 100644 --- a/cocos2d/core/CCNode.js +++ b/cocos2d/core/CCNode.js @@ -1352,6 +1352,28 @@ var Node = cc.Class({ return action; } : emptyFunc, + /** + * !#en Pause all actions running on the current node. Equals to `cc.director.getActionManager().pauseTarget(node)`. + * !#zh 暂停本节点上所有正在运行的动作。和 `cc.director.getActionManager().pauseTarget(node);` 等价。 + * @method pauseAllActions + * @example + * node.pauseAllActions(); + */ + pauseAllActions: ActionManagerExist ? function () { + cc.director.getActionManager().pauseTarget(this); + } : emptyFunc, + + /** + * !#en Resume all paused actions on the current node. Equals to `cc.director.getActionManager().resumeTarget(node)`. + * !#zh 恢复运行本节点上所有暂停的动作。和 `cc.director.getActionManager().resumeTarget(node);` 等价。 + * @method resumeAllActions + * @example + * node.resumeAllActions(); + */ + resumeAllActions: ActionManagerExist ? function () { + cc.director.getActionManager().resumeTarget(this); + } : emptyFunc, + /** * !#en Stops and removes all actions from the running action list . * !#zh 停止并且移除所有正在运行的动作列表。 From 667c78a44c381ae84a94244cb25e087bb7f25ef4 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Mon, 24 Apr 2017 16:22:32 +0800 Subject: [PATCH 2/2] Add pauseSystemEvents and resumeSystemEvents for cc.Node --- cocos2d/core/CCNode.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/cocos2d/core/CCNode.js b/cocos2d/core/CCNode.js index 1be0e34381..25e6993c95 100644 --- a/cocos2d/core/CCNode.js +++ b/cocos2d/core/CCNode.js @@ -1204,6 +1204,38 @@ var Node = cc.Class({ this._checkMouseListeners(); }, + /** + * !#en Pause node related system events registered with the current Node. Node system events includes touch and mouse events. + * If recursive is set to true, then this API will pause the node system events for the node and all nodes in its sub node tree. + * Reference: http://cocos2d-x.org/docs/editors_and_tools/creator-chapters/scripting/internal-events/ + * !#zh 暂停当前节点上注册的所有节点系统事件,节点系统事件包含触摸和鼠标事件。 + * 如果传递 recursive 为 true,那么这个 API 将暂停本节点和它的子树上所有节点的节点系统事件。 + * 参考:http://cocos.com/docs/creator/scripting/internal-events.html + * @method pauseSystemEvents + * @param {Boolean} recursive - Whether to pause node system events on the sub node tree. + * @example + * node.pauseSystemEvents(true); + */ + pauseSystemEvents (recursive) { + cc.eventManager.pauseTarget(this, recursive); + }, + + /** + * !#en Resume node related system events registered with the current Node. Node system events includes touch and mouse events. + * If recursive is set to true, then this API will resume the node system events for the node and all nodes in its sub node tree. + * Reference: http://cocos2d-x.org/docs/editors_and_tools/creator-chapters/scripting/internal-events/ + * !#zh 恢复当前节点上注册的所有节点系统事件,节点系统事件包含触摸和鼠标事件。 + * 如果传递 recursive 为 true,那么这个 API 将恢复本节点和它的子树上所有节点的节点系统事件。 + * 参考:http://cocos.com/docs/creator/scripting/internal-events.html + * @method resumeSystemEvents + * @param {Boolean} recursive - Whether to resume node system events on the sub node tree. + * @example + * node.resumeSystemEvents(true); + */ + resumeSystemEvents (recursive) { + cc.eventManager.resumeTarget(this, recursive); + }, + _checkTouchListeners () { if (!(this._objFlags & Destroying) && this._touchListener) { var i = 0;