fix api about event type

This commit is contained in:
Jare Guo
2017-05-19 10:55:56 +08:00
parent 01fb4ba903
commit 20155c6541
14 changed files with 67 additions and 59 deletions
+9 -9
View File
@@ -1239,7 +1239,7 @@ cc.js.addon(cc.Director.prototype, EventTarget.prototype);
* !#en The event projection changed of cc.Director.
* !#zh cc.Director 投影变化的事件。
* @event cc.Director.EVENT_PROJECTION_CHANGED
* @param {Event} event
* @param {Event.EventCustom} event
* @example
* cc.director.on(cc.Director.EVENT_PROJECTION_CHANGED, function(event) {
* cc.log("Projection changed.");
@@ -1251,7 +1251,7 @@ cc.Director.EVENT_PROJECTION_CHANGED = "director_projection_changed";
* !#en The event which will be triggered before loading a new scene.
* !#zh 加载新场景之前所触发的事件。
* @event cc.Director.EVENT_BEFORE_SCENE_LOADING
* @param {Event} event
* @param {Event.EventCustom} event
* @param {Vec2} event.detail - The loading scene name
*/
cc.Director.EVENT_BEFORE_SCENE_LOADING = "director_before_scene_loading";
@@ -1260,7 +1260,7 @@ cc.Director.EVENT_BEFORE_SCENE_LOADING = "director_before_scene_loading";
* !#en The event which will be triggered before launching a new scene.
* !#zh 运行新场景之前所触发的事件。
* @event cc.Director.EVENT_BEFORE_SCENE_LAUNCH
* @param {Event} event
* @param {Event.EventCustom} event
* @param {Vec2} event.detail - New scene which will be launched
*/
cc.Director.EVENT_BEFORE_SCENE_LAUNCH = "director_before_scene_launch";
@@ -1269,7 +1269,7 @@ cc.Director.EVENT_BEFORE_SCENE_LAUNCH = "director_before_scene_launch";
* !#en The event which will be triggered after launching a new scene.
* !#zh 运行新场景之后所触发的事件。
* @event cc.Director.EVENT_AFTER_SCENE_LAUNCH
* @param {Event} event
* @param {Event.EventCustom} event
* @param {Vec2} event.detail - New scene which is launched
*/
cc.Director.EVENT_AFTER_SCENE_LAUNCH = "director_after_scene_launch";
@@ -1278,7 +1278,7 @@ cc.Director.EVENT_AFTER_SCENE_LAUNCH = "director_after_scene_launch";
* !#en The event which will be triggered at the beginning of every frame.
* !#zh 每个帧的开始时所触发的事件。
* @event cc.Director.EVENT_BEFORE_UPDATE
* @param {Event} event
* @param {Event.EventCustom} event
*/
cc.Director.EVENT_BEFORE_UPDATE = "director_before_update";
@@ -1286,7 +1286,7 @@ cc.Director.EVENT_BEFORE_UPDATE = "director_before_update";
* !#en The event which will be triggered after engine and components update logic.
* !#zh 将在引擎和组件 “update” 逻辑之后所触发的事件。
* @event cc.Director.EVENT_AFTER_UPDATE
* @param {Event} event
* @param {Event.EventCustom} event
*/
cc.Director.EVENT_AFTER_UPDATE = "director_after_update";
@@ -1294,7 +1294,7 @@ cc.Director.EVENT_AFTER_UPDATE = "director_after_update";
* !#en The event which will be triggered before visiting the rendering scene graph.
* !#zh 访问渲染场景树之前所触发的事件。
* @event cc.Director.EVENT_BEFORE_VISIT
* @param {Event} event
* @param {Event.EventCustom} event
*/
cc.Director.EVENT_BEFORE_VISIT = "director_before_visit";
@@ -1304,7 +1304,7 @@ cc.Director.EVENT_BEFORE_VISIT = "director_before_visit";
* the render queue is ready but not rendered at this point.
* !#zh 访问渲染场景图之后所触发的事件,渲染队列已准备就绪,但在这一时刻还没有呈现在画布上。
* @event cc.Director.EVENT_AFTER_VISIT
* @param {Event} event
* @param {Event.EventCustom} event
*/
cc.Director.EVENT_AFTER_VISIT = "director_after_visit";
@@ -1312,7 +1312,7 @@ cc.Director.EVENT_AFTER_VISIT = "director_after_visit";
* !#en The event which will be triggered after the rendering process.
* !#zh 渲染过程之后所触发的事件。
* @event cc.Director.EVENT_AFTER_DRAW
* @param {Event} event
* @param {Event.EventCustom} event
*/
cc.Director.EVENT_AFTER_DRAW = "director_after_draw";
+11 -8
View File
@@ -1112,13 +1112,16 @@ var Node = cc.Class({
* 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
* @param {Event} callback.event event
* @param {Object} [target] - The target to invoke the callback, can be null
* @param {Boolean} [useCapture=false] - When set to true, the capture argument prevents callback
* from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
* When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
* 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.
* @typescript
* on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void
* on<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void
* @example
* 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);
@@ -2506,35 +2509,35 @@ if (CC_JSB) {
/**
* @event position-changed
* @param {Event} event
* @param {Event.EventCustom} event
* @param {Vec2} event.detail - The old position, but this parameter is only available in editor!
*/
/**
* @event size-changed
* @param {Event} event
* @param {Event.EventCustom} event
* @param {Size} event.detail - The old size, but this parameter is only available in editor!
*/
/**
* @event anchor-changed
* @param {Event} event
* @param {Event.EventCustom} event
*/
/**
* @event child-added
* @param {Event} event
* @param {Event.EventCustom} event
* @param {Node} event.detail - child
*/
/**
* @event child-removed
* @param {Event} event
* @param {Event.EventCustom} event
* @param {Node} event.detail - child
*/
/**
* @event child-reorder
* @param {Event} event
* @param {Event.EventCustom} event
*/
/**
* @event group-changed
* @param {Event} event
* @param {Event.EventCustom} event
*/
/**
+6 -3
View File
@@ -507,7 +507,7 @@ var Animation = cc.Class({
* @param {String} type - A string representing the event type to listen for.
* @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
* @param {Event} callback.event event
* @param {Object} [target] - The target to invoke the callback, can be null
* @param {Boolean} [useCapture=false] - When set to true, the capture argument prevents callback
* from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
@@ -515,6 +515,9 @@ var Animation = 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.
* @typescript
* on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void
* on<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void
* @example
* onPlay: function (event) {
* var state = event.detail; // state instanceof cc.AnimationState
@@ -522,7 +525,7 @@ var Animation = cc.Class({
* }
*
* // register event to all animation
* animation.on('', 'play', this.onPlay, this);
* animation.on('play', this.onPlay, this);
*/
on: function (type, callback, target, useCapture) {
this._init();
@@ -561,7 +564,7 @@ var Animation = cc.Class({
*
* @example
* // unregister event to all animation
* animation.off('', 'play', this.onPlay, this);
* animation.off('play', this.onPlay, this);
*/
off: function (type, callback, target, useCapture) {
this._init();
+1 -1
View File
@@ -664,6 +664,6 @@ cc.Button = module.exports = Button;
* !#zh
* 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。
* @event click
* @param {Event} event
* @param {Event.EventCustom} event
* @param {Button} event.detail - The Button component.
*/
+4 -4
View File
@@ -593,7 +593,7 @@ cc.EditBox = module.exports = EditBox;
* !#zh
* 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。
* @event editing-did-began
* @param {Event} event
* @param {Event.EventCustom} event
* @param {EditBox} event.detail - The EditBox component.
*/
@@ -603,7 +603,7 @@ cc.EditBox = module.exports = EditBox;
* !#zh
* 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。
* @event editing-did-ended
* @param {Event} event
* @param {Event.EventCustom} event
* @param {EditBox} event.detail - The EditBox component.
*/
@@ -613,7 +613,7 @@ cc.EditBox = module.exports = EditBox;
* !#zh
* 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。
* @event text-changed
* @param {Event} event
* @param {Event.EventCustom} event
* @param {EditBox} event.detail - The EditBox component.
*/
@@ -623,6 +623,6 @@ cc.EditBox = module.exports = EditBox;
* !#zh
* 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。
* @event editing-return
* @param {Event} event
* @param {Event.EventCustom} event
* @param {EditBox} event.detail - The EditBox component.
*/
+1 -1
View File
@@ -605,6 +605,6 @@ cc.PageView = module.exports = PageView;
* !#zh
* 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。
* @event page-turning
* @param {Event} event
* @param {Event.EventCustom} event
* @param {PageView} event.detail - The PageView component.
*/
+11 -11
View File
@@ -1510,7 +1510,7 @@ cc.ScrollView = module.exports = ScrollView;
* !#zh
* 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。
* @event scroll-to-top
* @param {Event} event
* @param {Event.EventCustom} event
* @param {ScrollView} event.detail - The ScrollView component.
*/
@@ -1520,7 +1520,7 @@ cc.ScrollView = module.exports = ScrollView;
* !#zh
* 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。
* @event scroll-to-bottom
* @param {Event} event
* @param {Event.EventCustom} event
* @param {ScrollView} event.detail - The ScrollView component.
*/
@@ -1530,7 +1530,7 @@ cc.ScrollView = module.exports = ScrollView;
* !#zh
* 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。
* @event scroll-to-left
* @param {Event} event
* @param {Event.EventCustom} event
* @param {ScrollView} event.detail - The ScrollView component.
*/
@@ -1540,7 +1540,7 @@ cc.ScrollView = module.exports = ScrollView;
* !#zh
* 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。
* @event scroll-to-right
* @param {Event} event
* @param {Event.EventCustom} event
* @param {ScrollView} event.detail - The ScrollView component.
*/
@@ -1550,7 +1550,7 @@ cc.ScrollView = module.exports = ScrollView;
* !#zh
* 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。
* @event scrolling
* @param {Event} event
* @param {Event.EventCustom} event
* @param {ScrollView} event.detail - The ScrollView component.
*/
@@ -1560,7 +1560,7 @@ cc.ScrollView = module.exports = ScrollView;
* !#zh
* 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。
* @event bounce-bottom
* @param {Event} event
* @param {Event.EventCustom} event
* @param {ScrollView} event.detail - The ScrollView component.
*/
@@ -1570,7 +1570,7 @@ cc.ScrollView = module.exports = ScrollView;
* !#zh
* 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。
* @event bounce-top
* @param {Event} event
* @param {Event.EventCustom} event
* @param {ScrollView} event.detail - The ScrollView component.
*/
@@ -1580,7 +1580,7 @@ cc.ScrollView = module.exports = ScrollView;
* !#zh
* 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。
* @event bounce-left
* @param {Event} event
* @param {Event.EventCustom} event
* @param {ScrollView} event.detail - The ScrollView component.
*/
@@ -1590,7 +1590,7 @@ cc.ScrollView = module.exports = ScrollView;
* !#zh
* 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。
* @event bounce-right
* @param {Event} event
* @param {Event.EventCustom} event
* @param {ScrollView} event.detail - The ScrollView component.
*/
@@ -1600,7 +1600,7 @@ cc.ScrollView = module.exports = ScrollView;
* !#zh
* 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。
* @event scroll-ended
* @param {Event} event
* @param {Event.EventCustom} event
* @param {ScrollView} event.detail - The ScrollView component.
*/
@@ -1610,6 +1610,6 @@ cc.ScrollView = module.exports = ScrollView;
* !#zh
* 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。
* @event touch-up
* @param {Event} event
* @param {Event.EventCustom} event
* @param {ScrollView} event.detail - The ScrollView component.
*/
+1 -1
View File
@@ -226,6 +226,6 @@ cc.Slider = module.exports = Slider;
* !#zh
* 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。
* @event slider
* @param {Event} event
* @param {Event.EventCustom} event
* @param {Slider} event.detail - The slider component.
*/
+1 -1
View File
@@ -224,6 +224,6 @@ cc.Toggle = module.exports = Toggle;
* !#zh
* 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。
* @event toggle
* @param {Event} event
* @param {Event.EventCustom} event
* @param {Toggle} event.detail - The Toggle component.
*/
+7 -7
View File
@@ -376,7 +376,7 @@ cc.VideoPlayer = module.exports = VideoPlayer;
* !#zh
* 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。
* @event ready-to-play
* @param {Event} event
* @param {Event.EventCustom} event
* @param {VideoPlayer} event.detail - The VideoPlayer component.
*/
@@ -386,7 +386,7 @@ cc.VideoPlayer = module.exports = VideoPlayer;
* !#zh
* 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。
* @event meta-loaded
* @param {Event} event
* @param {Event.EventCustom} event
* @param {VideoPlayer} event.detail - The VideoPlayer component.
*/
@@ -396,7 +396,7 @@ cc.VideoPlayer = module.exports = VideoPlayer;
* !#zh
* 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。
* @event clicked
* @param {Event} event
* @param {Event.EventCustom} event
* @param {VideoPlayer} event.detail - The VideoPlayer component.
*/
@@ -407,7 +407,7 @@ cc.VideoPlayer = module.exports = VideoPlayer;
* !#zh
* 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。
* @event playing
* @param {Event} event
* @param {Event.EventCustom} event
* @param {VideoPlayer} event.detail - The VideoPlayer component.
*/
@@ -417,7 +417,7 @@ cc.VideoPlayer = module.exports = VideoPlayer;
* !#zh
* 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。
* @event paused
* @param {Event} event
* @param {Event.EventCustom} event
* @param {VideoPlayer} event.detail - The VideoPlayer component.
*/
@@ -427,7 +427,7 @@ cc.VideoPlayer = module.exports = VideoPlayer;
* !#zh
* 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。
* @event stopped
* @param {Event} event
* @param {Event.EventCustom} event
* @param {VideoPlayer} event.detail - The VideoPlayer component.
*/
@@ -437,6 +437,6 @@ cc.VideoPlayer = module.exports = VideoPlayer;
* !#zh
* 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。
* @event completed
* @param {Event} event
* @param {Event.EventCustom} event
* @param {VideoPlayer} event.detail - The VideoPlayer component.
*/
+3 -3
View File
@@ -162,7 +162,7 @@ cc.WebView = module.exports = WebView;
* !#zh
* 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。
* @event loaded
* @param {Event} event
* @param {Event.EventCustom} event
* @param {WebView} event.detail - The WebView component.
*/
@@ -172,7 +172,7 @@ cc.WebView = module.exports = WebView;
* !#zh
* 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。
* @event loading
* @param {Event} event
* @param {Event.EventCustom} event
* @param {WebView} event.detail - The WebView component.
*/
@@ -182,6 +182,6 @@ cc.WebView = module.exports = WebView;
* !#zh
* 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。
* @event error
* @param {Event} event
* @param {Event.EventCustom} event
* @param {WebView} event.detail - The WebView component.
*/
+8 -2
View File
@@ -161,13 +161,16 @@ proto.hasEventListener = function (type, checkCapture) {
* @param {String} type - A string representing the event type to listen for.
* @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
* @param {Event} callback.event event
* @param {Object} [target] - The target to invoke the callback, can be null
* @param {Boolean} [useCapture=false] - When set to true, the capture argument prevents callback
* from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
* When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
* 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.
* @typescript
* on(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void
* on<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void
* @example
* node.on(cc.Node.EventType.TOUCH_END, function (event) {
* cc.log("this is callback");
@@ -273,12 +276,15 @@ proto.targetOff = function (target) {
* @param {String} type - A string representing the event type to listen for.
* @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
* @param {Event} callback.event event
* @param {Object} [target] - The target to invoke the callback, can be null
* @param {Boolean} [useCapture=false] - When set to true, the capture argument prevents callback
* from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE.
* When false, callback will NOT be invoked when event's eventPhase attribute value is CAPTURING_PHASE.
* Either way, callback will be invoked when event's eventPhase attribute value is AT_TARGET.
* @typescript
* once(type: string, callback: (event: Event.EventCustom) => void, target?: any, useCapture?: boolean): (event: Event.EventCustom) => void
* once<T>(type: string, callback: (event: T) => void, target?: any, useCapture?: boolean): (event: T) => void
* @example
* node.once(cc.Node.EventType.TOUCH_END, function (event) {
* cc.log("this is callback");
+1 -1
View File
@@ -1260,7 +1260,7 @@ if (CC_DEV) {
* !#zh
* 注意:此节点激活时,此事件仅从最顶部的节点发出。
* @event active-in-hierarchy-changed
* @param {Event} event
* @param {Event.EventCustom} event
*/
cc._BaseNode = module.exports = BaseNode;
+3 -7
View File
@@ -43,7 +43,7 @@ Function(
require('./predefine');
// load cocos2D engine code
// load Cocos2d engine code
var isMainProcess = CC_EDITOR && Editor.isMainProcess;
if (!isMainProcess) {
@@ -58,12 +58,8 @@ else {
require('./extends');
if (CC_EDITOR) {
/**
* In editor, in addition to the modules defined in cc scope, you can also access to the internal modules by using _require.
* @method _require
* @example
* var isDomNode = cc._require('./cocos2d/core/platform/utils').isDomNode;
*/
// In editor, in addition to the modules defined in cc scope, you can also access to the internal modules by using _require.
// var isDomNode = cc._require('./cocos2d/core/platform/utils').isDomNode;
cc._require = require;
/*
* Checks if the extension is loaded.