From 6e4a7a207cbe80853fd29313f481946962a99781 Mon Sep 17 00:00:00 2001 From: Jare Guo Date: Wed, 21 Sep 2016 17:31:16 +0800 Subject: [PATCH] improve event api doc --- cocos2d/core/CCNode.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cocos2d/core/CCNode.js b/cocos2d/core/CCNode.js index d4a6cc8069..fd1256d303 100644 --- a/cocos2d/core/CCNode.js +++ b/cocos2d/core/CCNode.js @@ -1121,7 +1121,8 @@ var Node = cc.Class({ * 同时您可以将事件派发到父节点或者通过调用 stopPropagation 拦截它。
* 推荐使用这种方式来监听节点上的触摸或鼠标事件,请不要在节点上直接使用 cc.eventManager。 * @method on - * @param {String} type - A string representing the event type to listen for. + * @param {String} type - A string representing the event type to listen for.
+ * See {{#crossLink "Node/position-changed:event"}}Node Events{{/crossLink}} for all builtin events. * @param {Function} callback - The callback that will be invoked when the event is dispatched. * The callback is ignored if it is a duplicate (the callbacks are unique). * @param {Event} callback.param event @@ -1132,11 +1133,12 @@ var Node = cc.Class({ * Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET. * @return {Function} - Just returns the incoming callback so you can save the anonymous function easier. * @example - * // add Node Touch Event + * this.node.on(cc.Node.EventType.TOUCH_START, this.memberFunction, this); // if "this" is component and the "memberFunction" declared in CCClass. * node.on(cc.Node.EventType.TOUCH_START, callback, this.node); * node.on(cc.Node.EventType.TOUCH_MOVE, callback, this.node); * node.on(cc.Node.EventType.TOUCH_END, callback, this.node); * node.on(cc.Node.EventType.TOUCH_CANCEL, callback, this.node); + * node.on("anchor-changed", callback, this); */ on: function (type, callback, target, useCapture) { var newAdded = false; @@ -1202,9 +1204,9 @@ var Node = cc.Class({ * one with capture and one without, each must be removed separately. Removal of a capturing callback * does not affect a non-capturing version of the same listener, and vice versa. * @example - * // remove Node TOUCH_START Event. - * node.on(cc.Node.EventType.TOUCH_START, callback, this.node); + * this.node.off(cc.Node.EventType.TOUCH_START, this.memberFunction, this); * node.off(cc.Node.EventType.TOUCH_START, callback, this.node); + * node.off("anchor-changed", callback, this); */ off: function (type, callback, target, useCapture) { this._EventTargetOff(type, callback, target, useCapture); @@ -1495,7 +1497,6 @@ if (CC_JSB) { * @param {Event} event * @param {Vec2} event.detail - The old position, but this parameter is only available in editor! */ -/** /** * @event size-changed * @param {Event} event