Date: Fri, 25 Mar 2016 16:22:12 +0800
Subject: [PATCH 05/12] fixed api doc error.
---
CCBoot.js | 2 +-
cocos2d/core/event-manager/CCEventListener.js | 51 ++++++++++++-------
cocos2d/core/event-manager/CCSystemEvent.js | 2 +-
cocos2d/core/platform/CCView.js | 18 +++----
cocos2d/core/platform/js.js | 5 +-
cocos2d/core/textures/CCTexture2D.js | 3 +-
cocos2d/core/value-types/CCSize.js | 9 ++--
7 files changed, 53 insertions(+), 37 deletions(-)
diff --git a/CCBoot.js b/CCBoot.js
index 2e58df600d..3c6691ed59 100644
--- a/CCBoot.js
+++ b/CCBoot.js
@@ -58,7 +58,7 @@ _p = null;
* @name cc.ENGINE_VERSION
*/
var engineVersion;
-engineVersion = '0.8.0-beta.9';
+engineVersion = '1.0.0-rc.1';
window['CocosEngine'] = cc.ENGINE_VERSION = engineVersion;
/**
diff --git a/cocos2d/core/event-manager/CCEventListener.js b/cocos2d/core/event-manager/CCEventListener.js
index de0a27baa8..12cf653fe4 100644
--- a/cocos2d/core/event-manager/CCEventListener.js
+++ b/cocos2d/core/event-manager/CCEventListener.js
@@ -33,12 +33,18 @@
*
* !#zh
* 封装用户的事件处理逻辑。
- * 注意:这是一个抽象类,开发者不应该直接实例化这个类,请参考 cc.EventListener.create。
+ * 注意:这是一个抽象类,开发者不应该直接实例化这个类,请参考 {{#crossLink "EventListener/create:method"}}cc.EventListener.create{{/crossLink}}。
*
* @class EventListener
+ */
+
+/**
+ * Constructor
+ * @method EventListener
* @param {Number} type
* @param {Number} listenerID
* @param {Number} callback
+ * @return {EventListner}
*/
cc.EventListener = cc._Class.extend(/** @lends cc.EventListener# */{
_onEvent: null, // Event callback function
@@ -247,59 +253,66 @@ cc.EventListener = cc._Class.extend(/** @lends cc.EventListener# */{
// event listener type
/**
* !#en The type code of unknown event listener.
- * !#zh 未知的事件监听器类型。
- * @property EventListener.UNKNOWN
- * @constant
+ * !#zh 未知的事件监听器类型
+ * @property UNKNOWN
* @type {Number}
+ * @static
*/
cc.EventListener.UNKNOWN = 0;
/*
* !#en The type code of one by one touch event listener.
- * !#zh 触摸事件监听器类型,触点会一个一个得分开被派发。
- * @constant
+ * !#zh 触摸事件监听器类型,触点会一个一个得分开被派发
+ * @property TOUCH_ONE_BY_ONE
* @type {Number}
+ * @static
*/
cc.EventListener.TOUCH_ONE_BY_ONE = 1;
/*
* !#en The type code of all at once touch event listener.
- * !#zh 触摸事件监听器类型,触点会被一次性全部派发。
- * @constant
+ * !#zh 触摸事件监听器类型,触点会被一次性全部派发
+ * @property TOUCH_ALL_AT_ONCE
* @type {Number}
+ * @static
*/
cc.EventListener.TOUCH_ALL_AT_ONCE = 2;
/**
* !#en The type code of keyboard event listener.
- * !#zh 键盘事件监听器类型。
- * @constant EventListener.KEYBOARD
+ * !#zh 键盘事件监听器类型
+ * @property KEYBOARD
* @type {Number}
+ * @static
*/
cc.EventListener.KEYBOARD = 3;
/*
* !#en The type code of mouse event listener.
- * !#zh 鼠标事件监听器类型。
- * @constant
+ * !#zh 鼠标事件监听器类型
+ * @property MOUSE
* @type {Number}
+ * @static
*/
cc.EventListener.MOUSE = 4;
/**
* !#en The type code of focus event listener.
- * !#zh 加速器事件监听器类型。
- * @constant EventListener.ACCELERATION
+ * !#zh 加速器事件监听器类型
+ * @property ACCELERATION
* @type {Number}
+ * @static
*/
cc.EventListener.ACCELERATION = 6;
/*
* !#en The type code of Focus change event listener.
- * !#zh 焦点事件监听器类型。
- * @constant
+ * !#zh 焦点事件监听器类型
+ * @property FOCUS
* @type {Number}
+ * @static
*/
cc.EventListener.FOCUS = 7;
/*
* !#en The type code of custom event listener.
- * !#zh 自定义事件监听器类型。
- * @constant
+ * !#zh 自定义事件监听器类型
+ * @property CUSTOM
* @type {Number}
+ * @static
*/
cc.EventListener.CUSTOM = 8;
@@ -456,9 +469,9 @@ cc._EventListenerTouchAllAtOnce.LISTENER_ID = "__cc_touch_all_at_once";
* all custom parameters will be polyfilled into the event listener object and can be accessed in handlers.
* !#zh 通过指定不同的 Event 对象来设置想要创建的事件监听器。
* @method create
- * @static
* @param {Object} argObj a json object
* @returns {EventListener}
+ * @static
* @example {@link utils/api/engine/docs/cocos2d/core/event-manager/CCEventListener/create.js}
*/
cc.EventListener.create = function(argObj){
diff --git a/cocos2d/core/event-manager/CCSystemEvent.js b/cocos2d/core/event-manager/CCSystemEvent.js
index f2dd6198f3..3a047b93d9 100644
--- a/cocos2d/core/event-manager/CCSystemEvent.js
+++ b/cocos2d/core/event-manager/CCSystemEvent.js
@@ -173,7 +173,7 @@ JS.mixin(EventMouse.prototype, {
/**
* !#en Returns the X axis delta distance from the previous location to current location.
* !#zh 获取鼠标距离上一次事件移动的 X 轴距离。
- * @method getDeltaX。
+ * @method getDeltaX
* @return {Number}
*/
getDeltaX: function () {
diff --git a/cocos2d/core/platform/CCView.js b/cocos2d/core/platform/CCView.js
index 0527739f43..93f65141ce 100644
--- a/cocos2d/core/platform/CCView.js
+++ b/cocos2d/core/platform/CCView.js
@@ -902,7 +902,7 @@ cc.ContainerStrategy = cc._Class.extend(/** @lends cc.ContainerStrategy# */{
/**
* Manipulation before appling the strategy
* @method preApply
- * @param {view} view - The target view
+ * @param {View} view - The target view
*/
preApply: function (view) {
},
@@ -910,7 +910,7 @@ cc.ContainerStrategy = cc._Class.extend(/** @lends cc.ContainerStrategy# */{
/**
* Function to apply this strategy
* @method apply
- * @param {view} view
+ * @param {View} view
* @param {Size} designedResolution
*/
apply: function (view, designedResolution) {
@@ -919,7 +919,7 @@ cc.ContainerStrategy = cc._Class.extend(/** @lends cc.ContainerStrategy# */{
/**
* Manipulation after applying the strategy
* @method postApply
- * @param {view} view The target view
+ * @param {View} view The target view
*/
postApply: function (view) {
@@ -1015,7 +1015,7 @@ cc.ContentStrategy = cc._Class.extend(/** @lends cc.ContentStrategy# */{
/**
* Manipulation before applying the strategy
* @method preApply
- * @param {view} view - The target view
+ * @param {View} view - The target view
*/
preApply: function (view) {
},
@@ -1025,7 +1025,7 @@ cc.ContentStrategy = cc._Class.extend(/** @lends cc.ContentStrategy# */{
* The return value is {scale: [scaleX, scaleY], viewport: {cc.Rect}},
* The target view can then apply these value to itself, it's preferred not to modify directly its private variables
* @method apply
- * @param {view} view
+ * @param {View} view
* @param {Size} designedResolution
* @return {Object} scaleAndViewportRect
*/
@@ -1036,7 +1036,7 @@ cc.ContentStrategy = cc._Class.extend(/** @lends cc.ContentStrategy# */{
/**
* Manipulation after applying the strategy
* @method postApply
- * @param {view} view - The target view
+ * @param {View} view - The target view
*/
postApply: function (view) {
}
@@ -1243,7 +1243,7 @@ cc.ResolutionPolicy = cc._Class.extend(/** @lends cc.ResolutionPolicy# */{
/**
* Manipulation before applying the resolution policy
* @method preApply
- * @param {view} view The target view
+ * @param {View} view The target view
*/
preApply: function (view) {
this._containerStrategy.preApply(view);
@@ -1255,7 +1255,7 @@ cc.ResolutionPolicy = cc._Class.extend(/** @lends cc.ResolutionPolicy# */{
* The return value is {scale: [scaleX, scaleY], viewport: {cc.Rect}},
* The target view can then apply these value to itself, it's preferred not to modify directly its private variables
* @method apply
- * @param {view} view - The target view
+ * @param {View} view - The target view
* @param {Size} designedResolution - The user defined design resolution
* @return {Object} An object contains the scale X/Y values and the viewport rect
*/
@@ -1267,7 +1267,7 @@ cc.ResolutionPolicy = cc._Class.extend(/** @lends cc.ResolutionPolicy# */{
/**
* Manipulation after appyling the strategy
* @method postApply
- * @param {view} view - The target view
+ * @param {View} view - The target view
*/
postApply: function (view) {
this._containerStrategy.postApply(view);
diff --git a/cocos2d/core/platform/js.js b/cocos2d/core/platform/js.js
index fa7dd3418e..03722ef655 100644
--- a/cocos2d/core/platform/js.js
+++ b/cocos2d/core/platform/js.js
@@ -45,8 +45,9 @@ function _copyprop(name, source, target) {
/**
* This module provides some JavaScript utilities.
- *
- * @module cc.js
+ * All members can be accessed with cc.js
+ * @module js
+ * @namespace cc.js
*/
var js = {
diff --git a/cocos2d/core/textures/CCTexture2D.js b/cocos2d/core/textures/CCTexture2D.js
index da92d5979c..63aa356492 100644
--- a/cocos2d/core/textures/CCTexture2D.js
+++ b/cocos2d/core/textures/CCTexture2D.js
@@ -33,8 +33,7 @@ require('../platform/CCClass');
/**
* The texture wrap mode
- * @class Texture2D.WrapMode
- * @static
+ * @enum Texture2D.WrapMode
*/
var WrapMode = cc.Enum({
/**
diff --git a/cocos2d/core/value-types/CCSize.js b/cocos2d/core/value-types/CCSize.js
index 62e0e1e351..21b736bcf1 100644
--- a/cocos2d/core/value-types/CCSize.js
+++ b/cocos2d/core/value-types/CCSize.js
@@ -27,12 +27,15 @@ var ValueType = require('./CCValueType');
var JS = require('../platform/js');
/**
- * cc.Size is the class for size object, please do not use its constructor to create sizes, use cc.size() alias function instead.
+ * cc.Size is the class for size object, please do not use its constructor to create sizes, use {{#crossLink "cc/size:method"}}{{/crossLink}} alias function instead.
* It will be deprecated soon, please use cc.Vec2 instead
- * @class cc.Size
+ * @class Size
+ */
+/**
+ * @method Size
* @param {Number} width
* @param {Number} height
- * @see cc.size
+ * @return {Size}
*/
function Size (width, height) {
if (width && typeof width === 'object') {
From 5fe7fffb00f5854ad7dfd44956593c0421f74d53 Mon Sep 17 00:00:00 2001
From: knoxHuang <821686174@qq.com>
Date: Fri, 25 Mar 2016 17:34:42 +0800
Subject: [PATCH 06/12] update spine API and fix CCNode on example error
---
cocos2d/core/CCNode.js | 2 +-
extensions/spine/Skeleton.js | 26 ++++++++++++--------------
extensions/spine/index.js | 4 ++--
3 files changed, 15 insertions(+), 17 deletions(-)
diff --git a/cocos2d/core/CCNode.js b/cocos2d/core/CCNode.js
index 94dcb66443..0381ec1363 100644
--- a/cocos2d/core/CCNode.js
+++ b/cocos2d/core/CCNode.js
@@ -1038,7 +1038,7 @@ var Node = cc.Class({
* 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_END, callback, this.node);
+ * node.on(cc.Node.EventType.TOUCH_CANCEL, callback, this.node);
*/
on: function (type, callback, target) {
if (_touchEvents.indexOf(type) !== -1) {
diff --git a/extensions/spine/Skeleton.js b/extensions/spine/Skeleton.js
index a7e8158112..401cb5251f 100644
--- a/extensions/spine/Skeleton.js
+++ b/extensions/spine/Skeleton.js
@@ -402,7 +402,7 @@ sp.Skeleton = cc.Class({
/**
* !#en Sets the bones and slots to the setup pose.
- * !#zh 设置 bones 和 slots 的动作。
+ * !#zh 还原到起始动作
* @method setToSetupPose
*/
setToSetupPose: function () {
@@ -416,8 +416,8 @@ sp.Skeleton = cc.Class({
* Sets the bones to the setup pose,
* using the values from the `BoneData` list in the `SkeletonData`.
* !#zh
- * 设置 bones 和 slots 的动作,
- * 使用来自在 `SkeletonData` 的 `BoneData` 列表中的值。
+ * 设置 bone 到起始动作
+ * 使用 SkeletonData 中的 BoneData 列表中的值。
* @method setBonesToSetupPose
*/
setBonesToSetupPose: function () {
@@ -431,8 +431,8 @@ sp.Skeleton = cc.Class({
* Sets the slots to the setup pose,
* using the values from the `SlotData` list in the `SkeletonData`.
* !#zh
- * 设置 bones 和 slots 的动作,
- * 使用来自在 `SkeletonData` 的 `SlotData` 列表中的值。
+ * 设置 slot 到起始动作。
+ * 使用 SkeletonData 中的 SlotData 列表中的值。
* @method setSlotsToSetupPose
*/
setSlotsToSetupPose: function () {
@@ -447,7 +447,7 @@ sp.Skeleton = cc.Class({
* This does a string comparison for every bone.
* !#zh
* 通过名称查找 bone。
- * 这里对每个 bone 的名称进行了比较。
+ * 这里对每个 bone 的名称进行了对比。
* @method findBone
* @param {String} boneName
* @return {spine.Bone}
@@ -485,7 +485,7 @@ sp.Skeleton = cc.Class({
* !#zh
* 按名称查找皮肤,激活该皮肤。
* 这里对每个皮肤的名称进行了比较。
- * 注意:设置在皮肤不会改变它的 attachments 是可见的。
+ * 注意:设置皮肤不会改变 attachment 的可见性。。
* @method setSkin
* @param {String} skinName
* @return {spine.Skin}
@@ -503,7 +503,7 @@ sp.Skeleton = cc.Class({
* The skeleton looks first in its skin, then in the skeleton data’s default skin.
* !#zh
* 通过 slot 和 attachment 的名称获取 attachment。
- * Skeleton 优先查找它的皮肤,然后才是 Skeleton Data 中默认的 Skin。
+ * Skeleton 优先查找它的皮肤,然后才是 Skeleton Data 中默认的皮肤。
* @method getAttachment
* @param {String} slotName
* @param {String} attachmentName
@@ -522,7 +522,7 @@ sp.Skeleton = cc.Class({
* The skeleton looks first in its skin, then in the skeleton data’s default skin.
* !#zh
* 通过 slot 和 attachment 的名字来设置 attachment。
- * Skeleton 优先查找它的皮肤,然后才是 Skeleton Data 中默认的 Skin。
+ * Skeleton 优先查找它的皮肤,然后才是 Skeleton Data 中默认的皮肤。
* @method setAttachment
* @param {String} slotName
* @param {String} attachmentName
@@ -576,9 +576,7 @@ sp.Skeleton = cc.Class({
* !#en
* Mix applies all keyframe values,
* interpolated for the specified time and mixed with the current values.
- * !#zh
- * 混合应用所有关键帧值,
- * 插入指定的时间和混合的当前值
+ * !#zh 为所有关键帧设定混合及混合时间(从当前值开始差值)。
* @method setMix
* @param {String} fromAnimation
* @param {String} toAnimation
@@ -632,7 +630,7 @@ sp.Skeleton = cc.Class({
/**
* !#en Adds an animation to be played delay seconds after the current or last queued animation.
- * !#zh 添加一个动画到当前,或者是动画队列尾部后会再 “delay” 秒后播放?
+ * !#zh 添加一个动画到动画队列尾部,还可以延迟指定的秒数。
* @method addAnimation
* @param {Number} trackIndex
* @param {String} name
@@ -663,7 +661,7 @@ sp.Skeleton = cc.Class({
/**
* !#en Clears all tracks of animation state.
- * !#zh 清除所有 tracks 的动画状态。
+ * !#zh 清除所有 track 的动画状态。
* @method clearTracks
*/
clearTracks: function () {
diff --git a/extensions/spine/index.js b/extensions/spine/index.js
index 713f9c081d..c80af7b026 100644
--- a/extensions/spine/index.js
+++ b/extensions/spine/index.js
@@ -27,7 +27,7 @@
* The global main namespace of Spine, all classes, functions,
* properties and constants of Spine are defined in this namespace
* !#zh
- * Spine 是全局的命名空间,
+ * Spine 的全局的命名空间,
* 与 Spine 相关的所有的类,函数,属性,常量都在这个命名空间中定义。
* @module sp
* @main sp
@@ -103,7 +103,7 @@ if (!CC_EDITOR || !Editor.isCoreLevel) {
if (!CC_JSB) {
/**
* !#en
- * The official spine runtime.
+ * The official spine runtime.
* See http://en.esotericsoftware.com/spine-using-runtimes
* !#zh
* 官方 Spine Runtime。
From ceb4064f84c22904793b96347c1c76e91a494576 Mon Sep 17 00:00:00 2001
From: knoxHuang <821686174@qq.com>
Date: Fri, 25 Mar 2016 18:30:34 +0800
Subject: [PATCH 07/12] fix Audio Source bug
---
cocos2d/core/components/CCAudioSource.js | 6 ------
1 file changed, 6 deletions(-)
diff --git a/cocos2d/core/components/CCAudioSource.js b/cocos2d/core/components/CCAudioSource.js
index a16ee78ca5..b0bbd238cd 100644
--- a/cocos2d/core/components/CCAudioSource.js
+++ b/cocos2d/core/components/CCAudioSource.js
@@ -182,12 +182,6 @@ var AudioSource = cc.Class({
}
},
- onLoad: function () {
- if ( this.isPlaying ) {
- this.stop();
- }
- },
-
onEnable: function () {
if ( this.playOnLoad ) {
this.play();
From b2c6ed3dfda305accc7a849804a0d30b368d6d36 Mon Sep 17 00:00:00 2001
From: knoxHuang <821686174@qq.com>
Date: Fri, 25 Mar 2016 18:35:27 +0800
Subject: [PATCH 08/12] update Tiled Map API
---
cocos2d/tilemap/CCTMXObjectGroup.js | 75 +++++++++---
cocos2d/tilemap/CCTiledLayer.js | 179 ++++++++++++++++++++++------
cocos2d/tilemap/CCTiledMap.js | 154 +++++++++++++++++-------
3 files changed, 309 insertions(+), 99 deletions(-)
diff --git a/cocos2d/tilemap/CCTMXObjectGroup.js b/cocos2d/tilemap/CCTMXObjectGroup.js
index 6589d7c607..352167c511 100644
--- a/cocos2d/tilemap/CCTMXObjectGroup.js
+++ b/cocos2d/tilemap/CCTMXObjectGroup.js
@@ -25,8 +25,9 @@
****************************************************************************/
/**
- * cc.TMXObjectGroup represents the TMX object group.
- * @class
+ * !#en cc.TMXObjectGroup represents the TMX object group.
+ * !#zh TMXObjectGroup 用来表示 TMX 对象组。
+ * @class TMXObjectGroup
* @extends cc._Class
*
* @property {Array} properties - Properties from the group. They can be added using tilemap editors
@@ -52,16 +53,24 @@ cc.TMXObjectGroup = cc._Class.extend(/** @lends cc.TMXObjectGroup# */{
},
/**
- * Offset position of child objects
- * @return {cc.Vec2}
+ * !#en Offset position of child objects.
+ * !#zh 获取子对象的偏移位置。
+ * @method getPositionOffset
+ * @return {Vec2}
+ * @example
+ * var offset = tMXObjectGroup.getPositionOffset();
*/
getPositionOffset:function () {
return cc.p(this._positionOffset);
},
/**
- * Offset position of child objects
- * @param {cc.Vec2} offset
+ * !#en Offset position of child objects.
+ * !#zh 设置子对象的偏移位置。
+ * @method setPositionOffset
+ * @param {Vec2} offset
+ * @example
+ * tMXObjectGroup.setPositionOffset(cc.v2(5, 5));
*/
setPositionOffset:function (offset) {
this._positionOffset.x = offset.x;
@@ -69,32 +78,48 @@ cc.TMXObjectGroup = cc._Class.extend(/** @lends cc.TMXObjectGroup# */{
},
/**
- * List of properties stored in a dictionary
+ * !#en List of properties stored in a dictionary.
+ * !#zh 获取存储在字典中的属性队列。
+ * @method getProperties
* @return {Array}
+ * @example
+ * var offset = tMXObjectGroup.getProperties();
*/
getProperties:function () {
return this.properties;
},
/**
- * List of properties stored in a dictionary
- * @param {object} Var
+ * !#en List of properties stored in a dictionary.
+ * !#zh 设置属性队列。
+ * @method setProperties
+ * @param {Object} Var
+ * @example
+ * tMXObjectGroup.setProperties(obj);
*/
setProperties:function (Var) {
this.properties.push(Var);
},
/**
- * Gets the Group name.
+ * !#en Gets the Group name.
+ * !#zh 获取组名称。
+ * @method getGroupName
* @return {String}
+ * @example
+ * var groupName = tMXObjectGroup.getGroupName;
*/
getGroupName:function () {
return this.groupName.toString();
},
/**
- * Set the Group name
+ * !#en Set the Group name.
+ * !#zh 设置组名称。
+ * @method setGroupName
* @param {String} groupName
+ * @example
+ * tMXObjectGroup.setGroupName("New Group");
*/
setGroupName:function (groupName) {
this.groupName = groupName;
@@ -103,7 +128,7 @@ cc.TMXObjectGroup = cc._Class.extend(/** @lends cc.TMXObjectGroup# */{
/**
* Return the value for the specific property name
* @param {String} propertyName
- * @return {object}
+ * @return {Object}
*/
propertyNamed:function (propertyName) {
return this.properties[propertyName];
@@ -121,10 +146,16 @@ cc.TMXObjectGroup = cc._Class.extend(/** @lends cc.TMXObjectGroup# */{
},
/**
- * Return the dictionary for the specific object name.
- * It will return the 1st object found on the array for the given name.
+ * !#en
+ * Return the dictionary for the specific object name.
+ * It will return the 1st object found on the array for the given name.
+ * !#zh 获取指定对象名的字典。
+ * 它将返回的是符号指定名字的数组中第一个对象。
+ * @method getObject
* @param {String} objectName
- * @return {object|Null}
+ * @return {Object|Null}
+ * @example
+ * var object = tMXObjectGroup.getObject("Group");
*/
getObject: function(objectName){
if (this._objects && this._objects.length > 0) {
@@ -140,16 +171,24 @@ cc.TMXObjectGroup = cc._Class.extend(/** @lends cc.TMXObjectGroup# */{
},
/**
- * Gets the objects.
+ * !#en Gets the objects.
+ * !#zh 获取对象数组。
+ * @method getObjects
* @return {Array}
+ * @example
+ * var objects = tMXObjectGroup.getObjects();
*/
getObjects:function () {
return this._objects;
},
/**
- * Set the objects.
- * @param {object} objects
+ * !#en Set the objects.
+ * !#zh 设置对象数组。
+ * @method setObjects
+ * @param {Object} objects
+ * @example
+ * tMXObjectGroup.setObjects(objects);
*/
setObjects:function (objects) {
this._objects.push(objects);
diff --git a/cocos2d/tilemap/CCTiledLayer.js b/cocos2d/tilemap/CCTiledLayer.js
index d1d36a56a3..072c724cb7 100644
--- a/cocos2d/tilemap/CCTiledLayer.js
+++ b/cocos2d/tilemap/CCTiledLayer.js
@@ -24,7 +24,8 @@
****************************************************************************/
/**
- * Render the TMX layer.
+ * !#en Render the TMX layer.
+ * !#zh 渲染 TMX layer。
* @class TiledLayer
* @extends _SGComponent
*/
@@ -90,9 +91,13 @@ var TiledLayer = cc.Class({
},
/**
- * Gets the layer name
+ * !#en Gets the layer name.
+ * !#zh 获取层的名称。
* @method getLayerName
* @return {String}
+ * @example
+ * var layerName = tiledLayer.getLayerName();
+ * cc.log(layerName);
*/
getLayerName: function() {
if (this._sgNode) {
@@ -102,9 +107,12 @@ var TiledLayer = cc.Class({
},
/**
- * Set the layer name
+ * !#en Set the layer name.
+ * !#zh 设置层的名称
* @method SetLayerName
* @param {String} layerName
+ * @example
+ * tiledLayer.setLayerName("New Layer");
*/
setLayerName:function (layerName) {
if (this._sgNode) {
@@ -113,10 +121,14 @@ var TiledLayer = cc.Class({
},
/**
- * Return the value for the specific property name
+ * !#en Return the value for the specific property name.
+ * !#zh 获取指定属性名的值。
* @method getProperty
* @param {String} propertyName
* @return {*}
+ * @example
+ * var property = tiledLayer.getProperty("info");
+ * cc.log(property);
*/
getProperty:function (propertyName) {
if (this._sgNode) {
@@ -127,11 +139,17 @@ var TiledLayer = cc.Class({
},
/**
- * Returns the position in pixels of a given tile coordinate
+ * !#en Returns the position in pixels of a given tile coordinate.
+ * !#zh 获取指定坐标的位置(以点为单位)。
* @method getPositionAt
* @param {Vec2|Number} pos position or x
* @param {Number} [y]
* @return {Vec2}
+ * @example
+ * var pos = tiledLayer.getPositionAt(cc.v2(0, 0));
+ * cc.log("Pos: " + pos);
+ * var pos = tiledLayer.getPositionAt(0, 0);
+ * cc.log("Pos: " + pos);
*/
getPositionAt:function (pos, y) {
if (this._sgNode) {
@@ -144,10 +162,14 @@ var TiledLayer = cc.Class({
},
/**
- * Removes a tile at given tile coordinate
+ * !#en Removes a tile at given tile coordinate.
+ * !#zh 删除指定坐标上的 tile。
* @method removeTileAt
* @param {Vec2|Number} pos position or x
* @param {Number} [y]
+ * @example
+ * tiledLayer.removeTileAt(cc.v2(0, 0));
+ * tiledLayer.removeTileAt(0, 0);
*/
removeTileAt:function (pos, y) {
if (this._sgNode) {
@@ -158,14 +180,21 @@ var TiledLayer = cc.Class({
},
/**
- * Sets the tile gid (gid = tile global id) at a given tile coordinate.
+ * !#en
+ * Sets the tile gid (gid = tile global id) at a given tile coordinate.
* The Tile GID can be obtained by using the method "tileGIDAt" or by using the TMX editor . Tileset Mgr +1.
- * If a tile is already placed at that position, then it will be removed.
+ * If a tile is already placed at that position, then it will be removed.
+ * !#zh
+ * 设置给定坐标的 tile 的 gid (gid = tile 全局 id),
+ * tile 的 GID 可以使用方法 “tileGIDAt” 来获得。
+ * 如果一个 tile 已经放在那个位置,那么它将被删除。
* @method setTileGID
* @param {Number} gid
* @param {Vec2|Number} posOrX position or x
* @param {Number} flagsOrY flags or y
* @param {Number} [flags]
+ * @example
+ * tiledLayer.setTileGID(1001, 10, 10, 1)
*/
setTileGID: function(gid, posOrX, flagsOrY, flags) {
if (this._sgNode) {
@@ -199,13 +228,20 @@ var TiledLayer = cc.Class({
//},
/**
+ * !#en
* Returns the tile gid at a given tile coordinate.
* if it returns 0, it means that the tile is empty.
* This method requires the the tile map has not been previously released (eg. don't call layer.releaseMap())
+ * !#zh
+ * 通过给定的 tile 坐标、flags(可选)返回 tile 的 GID.
+ * 如果它返回 0,则表示该文件为空。
+ * 该方法要求 tile 地图之前没有被释放过(如:没有调用过layer.releaseMap()).
* @method getTileGIDAt
* @param {Vec2|Number} pos or x
* @param {Number} [y]
* @return {Number}
+ * @example
+ * var tileGid = tiledLayer.getTileGIDAt(0, 0);
*/
getTileGIDAt:function (pos, y) {
if (this._sgNode) {
@@ -217,16 +253,26 @@ var TiledLayer = cc.Class({
},
/**
- * Returns the tile (_ccsg.Sprite) at a given a tile coordinate.
+ * !#en
+ * Returns the tile (_ccsg.Sprite) at a given a tile coordinate.
* The returned _ccsg.Sprite will be already added to the _ccsg.TMXLayer. Don't add it again.
* The _ccsg.Sprite can be treated like any other _ccsg.Sprite: rotated, scaled, translated, opacity, color, etc.
* You can remove either by calling:
* - layer.removeChild(sprite, cleanup);
- * - or layer.removeTileAt(ccp(x,y));
+ * - or layer.removeTileAt(ccp(x,y));
+ * !#zh
+ * 通过指定的 tile 坐标获取对应的 tile(Sprite)。 返回的 tile(Sprite) 应是已经添加到 TMXLayer,请不要重复添加。
+ * 这个 tile(Sprite) 如同其他的 Sprite 一样,可以旋转、缩放、翻转、透明化、设置颜色等。
+ * 你可以通过调用以下方法来对它进行删除:
+ * 1. layer.removeChild(sprite, cleanup);
+ * 2. 或 layer.removeTileAt(cc.v2(x,y));
* @method getTileAt
- * @param {cc.Vec2|Number} pos or x
+ * @param {Vec2|Number} pos or x
* @param {Number} [y]
* @return {_ccsg.Sprite}
+ * @example
+ * var title = tiledLayer.getTileAt(100, 100);
+ * cc.log(title);
*/
getTileAt: function (pos, y) {
if (this._sgNode) {
@@ -238,10 +284,17 @@ var TiledLayer = cc.Class({
},
/**
- * Dealloc the map that contains the tile position from memory.
+ * !#en
+ * Dealloc the map that contains the tile position from memory.
* Unless you want to know at runtime the tiles positions, you can safely call this method.
- * If you are going to call layer.getTileGIDAt() then, don't release the map
+ * If you are going to call layer.getTileGIDAt() then, don't release the map.
+ * !#zh
+ * 从内存中释放包含 tile 位置信息的地图。
+ * 除了在运行时想要知道 tiles 的位置信息外,你都可安全的调用此方法。
+ * 如果你之后还要调用 layer.tileGIDAt(), 请不要释放地图.
* @method releaseMap
+ * @example
+ * tiledLayer.releaseMap();
*/
releaseMap:function () {
if (this._sgNode) {
@@ -250,10 +303,13 @@ var TiledLayer = cc.Class({
},
/**
- * Sets the untransformed size of the _ccsg.TMXLayer.
+ * !#en Sets the untransformed size of the _ccsg.TMXLayer.
+ * !#zh 设置不转换节点的大小。
* @method setContentSize
- * @param {cc.Size|Number} size The untransformed size of the _ccsg.TMXLayer or The untransformed size's width of the TMXLayer.
+ * @param {Size|Number} size The untransformed size of the _ccsg.TMXLayer or The untransformed size's width of the TMXLayer.
* @param {Number} [height] The untransformed size's height of the _ccsg.TMXLayer.
+ * @example
+ * tiledLayer.setContentSize(100, 100);
*/
setContentSize:function (size, height) {
if (this._sgNode) {
@@ -264,9 +320,13 @@ var TiledLayer = cc.Class({
},
/**
- * Return texture of cc.SpriteBatchNode
+ * !#en Return texture of cc.SpriteBatchNode.
+ * !#zh 获取纹理。
* @method getTexture
- * @return {cc.Texture2D}
+ * @return {Texture2D}
+ * @example
+ * var texture = tiledLayer.getTexture();
+ * cc.log("Texture: " + texture);
*/
getTexture: function(){
if (this._sgNode) {
@@ -276,9 +336,12 @@ var TiledLayer = cc.Class({
},
/**
- * Set the texture of cc.SpriteBatchNode
+ * !#en Set the texture of cc.SpriteBatchNode.
+ * !#zh 设置纹理。
* @method setTexture
- * @param {cc.Texture2D} texture
+ * @param {Texture2D} texture
+ * @example
+ * tiledLayer.setTexture(texture);
*/
setTexture: function(texture){
if (this._sgNode) {
@@ -287,9 +350,13 @@ var TiledLayer = cc.Class({
},
/**
- * Gets layer size.
+ * !#en Gets layer size.
+ * !#zh 获得层大小。
* @method getLayerSize
- * @return {cc.Size}
+ * @return {Size}
+ * @example
+ * var size = tiledLayer.getLayerSize();
+ * cc.log("layer size: " + size);
*/
getLayerSize:function () {
if (this._sgNode) {
@@ -299,9 +366,12 @@ var TiledLayer = cc.Class({
},
/**
- * Set layer size
+ * !#en Set layer size.
+ * !#zh 设置层大小。
* @method setLayerSize
- * @param {cc.Size} layerSize
+ * @param {Size} layerSize
+ * @example
+ * tiledLayer.setLayerSize(new cc.size(5, 5));
*/
setLayerSize:function (layerSize) {
if (this._sgNode) {
@@ -310,9 +380,13 @@ var TiledLayer = cc.Class({
},
/**
- * Size of the map's tile (could be different from the tile's size)
+ * !#en Size of the map's tile (could be different from the tile's size).
+ * !#zh 获取 tile 的大小( tile 的大小可能会有所不同)。
* @method getMapTileSize
- * @return {cc.Size}
+ * @return {Size}
+ * @example
+ * var mapTileSize = tiledLayer.getMapTileSize();
+ * cc.log("MapTile size: " + mapTileSize);
*/
getMapTileSize:function () {
if (this._sgNode) {
@@ -322,9 +396,12 @@ var TiledLayer = cc.Class({
},
/**
- * Set the map tile size.
+ * !#en Set the map tile size.
+ * !#zh 设置 tile 的大小。
* @method setMapTileSize
- * @param {cc.Size} tileSize
+ * @param {Size} tileSize
+ * @example
+ * tiledLayer.setMapTileSize(new cc.size(10, 10));
*/
setMapTileSize:function (tileSize) {
if (this._sgNode) {
@@ -333,9 +410,12 @@ var TiledLayer = cc.Class({
},
/**
- * Pointer to the map of tiles
+ * !#en Pointer to the map of tiles.
+ * !#zh 获取地图 tiles。
* @method getTiles
* @return {Array}
+ * @example
+ * var tiles = tiledLayer.getTiles();
*/
getTiles:function () {
if (this._sgNode) {
@@ -345,9 +425,12 @@ var TiledLayer = cc.Class({
},
/**
- * Pointer to the map of tiles
+ * !#en Pointer to the map of tiles.
+ * !#zh 设置地图 tiles
* @method setTiles
* @param {Array} tiles
+ * @example
+ * tiledLayer.setTiles(tiles);
*/
setTiles:function (tiles) {
if (this._sgNode) {
@@ -356,9 +439,12 @@ var TiledLayer = cc.Class({
},
/**
- * Tile set information for the layer
+ * !#en Tile set information for the layer.
+ * !#zh 获取 layer 的 Tileset 信息。
* @method getTileset
- * @return {cc.TMXTilesetInfo}
+ * @return {TMXTilesetInfo}
+ * @example
+ * var tileset = tiledLayer.getTileset();
*/
getTileset:function () {
if (this._sgNode) {
@@ -368,9 +454,12 @@ var TiledLayer = cc.Class({
},
/**
- * Tile set information for the layer
+ * !#en Tile set information for the layer.
+ * !#zh 设置 layer 的 Tileset 信息。
* @method setTileset
- * @param {cc.TMXTilesetInfo} tileset
+ * @param {TMXTilesetInfo} tileset
+ * @example
+ * tiledLayer.getTileset(tileset);
*/
setTileset:function (tileset) {
if (this._sgNode) {
@@ -379,9 +468,13 @@ var TiledLayer = cc.Class({
},
/**
- * Layer orientation, which is the same as the map orientation
+ * !#en Layer orientation, which is the same as the map orientation.
+ * !#zh 获取 Layer 方向(同地图方向)。
* @method getLayerOrientation
* @return {Number}
+ * @example
+ * var orientation = tiledLayer.getLayerOrientation();
+ * cc.log("Layer Orientation: " + orientation);
*/
getLayerOrientation:function () {
if (this._sgNode) {
@@ -391,9 +484,12 @@ var TiledLayer = cc.Class({
},
/**
- * Layer orientation, which is the same as the map orientation
+ * !#en Layer orientation, which is the same as the map orientation.
+ * !#zh 设置 Layer 方向(同地图方向)。
* @method setLayerOrientation
- * @param {Number} orientation
+ * @param {TiledMap.Orientation} orientation
+ * @example
+ * tiledLayer.setLayerOrientation(TiledMap.Orientation.ORTHO);
*/
setLayerOrientation:function (orientation) {
if (this._sgNode) {
@@ -402,9 +498,13 @@ var TiledLayer = cc.Class({
},
/**
- * properties from the layer. They can be added using Tiled
+ * !#en properties from the layer. They can be added using Tiled.
+ * !#zh 获取 layer 的属性,可以被当作 Tile 添加。
* @method getProperties
* @return {Array}
+ * @example
+ * var properties = tiledLayer.getProperties();
+ * cc.log("Properties: " + properties);
*/
getProperties:function () {
if (this._sgNode) {
@@ -414,9 +514,12 @@ var TiledLayer = cc.Class({
},
/**
- * properties from the layer. They can be added using Tiled
+ * !#en properties from the layer. They can be added using Tiled.
+ * !#zh 设置层属性。
* @method setProperties
* @param {Array} properties
+ * @example
+ * tiledLayer.setLayerOrientation(properties);
*/
setProperties:function (properties) {
if (this._sgNode) {
diff --git a/cocos2d/tilemap/CCTiledMap.js b/cocos2d/tilemap/CCTiledMap.js
index 78fc644474..cc1823ba0c 100644
--- a/cocos2d/tilemap/CCTiledMap.js
+++ b/cocos2d/tilemap/CCTiledMap.js
@@ -24,13 +24,15 @@
****************************************************************************/
/**
- * The orientation of tiled map
+ * !#en The orientation of tiled map.
+ * !#zh Tiled Map 地图定向。
* @enum TiledMap.Orientation
* @static
*/
var Orientation = cc.Enum({
/**
- * Orthogonal orientation
+ * !#en Orthogonal orientation.
+ * !#zh 直角鸟瞰地图(90°地图)。
* @property ORTHO
* @type {Number}
* @static
@@ -38,7 +40,8 @@ var Orientation = cc.Enum({
ORTHO: 0,
/**
- * Hexagonal orientation
+ * !#en Hexagonal orientation.
+ * !#zh 六边形地图
* @property HEX
* @type {Number}
* @static
@@ -46,7 +49,8 @@ var Orientation = cc.Enum({
HEX: 1,
/**
- * Isometric orientation
+ * Isometric orientation.
+ * 等距斜视地图(斜45°地图)。
* @property ISO
* @type {Number}
* @static
@@ -54,8 +58,8 @@ var Orientation = cc.Enum({
ISO: 2
});
-/**
- * The property type of tiled map
+/*
+ * The property type of tiled map.
* @enum TiledMap.Property
* @static
*/
@@ -103,8 +107,8 @@ var Property = cc.Enum({
TILE: 5
});
-/**
- * The tile flags of tiled map
+/*
+ * The tile flags of tiled map.
* @enum TiledMap.TileFlag
* @static
*/
@@ -146,7 +150,8 @@ var TileFlag = cc.Enum({
});
/**
- * Renders a TMX Tile Map in the scene.
+ * !#en Renders a TMX Tile Map in the scene.
+ * !#zh 渲染一个 tmx 地图编辑器导出 Tile Map 的场景。
* @class TiledMap
* @extends Component
*/
@@ -177,8 +182,9 @@ var TiledMap = cc.Class({
},
/**
- * The tmx file.
- * @property {string} tmxFile
+ * !#en The tmx file.
+ * !#zh tmx 文件。
+ * @property {String} tmxFile
* @default ""
*/
_tmxFile: {
@@ -200,8 +206,9 @@ var TiledMap = cc.Class({
},
/**
- * The event handler to be called when the map is loaded.
- * @property {cc.Component.EventHandler} mapLoaded
+ * !#en The event handler to be called when the map is loaded.
+ * !#zh 在加载在地图时要调用的事件处理程序。
+ * @property {Component.EventHandler} mapLoaded
*/
mapLoaded: {
default: [],
@@ -210,96 +217,135 @@ var TiledMap = cc.Class({
},
/**
- * Gets the map size.
+ * !#en Gets the map size.
+ * !#zh 获取地图背景的大小。
* @method getMapSize
- * @return {cc.Size}
+ * @return {Size}
+ * @example
+ * var mapSize = tiledMap.getMapSize();
+ * cc.log("Map Size: " + mapSize);
*/
getMapSize:function () {
return this._sgNode.getMapSize();
},
/**
- * Set the map size.
+ * !#en Set the map size.
+ * !#zh 设置地图背景的大小。
* @method setMapSize
- * @param {cc.Size} mapSize
+ * @param {Size} mapSize
+ * @example
+ * tiledMap.setMapSize(new cc.size(960, 640));
*/
setMapSize:function (mapSize) {
this._sgNode.setMapSize(mapSize);
},
/**
- * Gets the tile size.
+ * !#en Gets the tile size.
+ * !#zh 获取地图背景中砖块元素的大小。
* @method getTileSize
- * @return {cc.Size}
+ * @return {Size}
+ * @example
+ * var tileSize = tiledMap.getTileSize();
+ * cc.log("Tile Size: " + tileSize);
*/
getTileSize:function () {
return this._sgNode.getTileSize();
},
/**
- * Set the tile size
+ * !#en Set the tile size.
+ * !#zh 设置地图背景中砖块元素的大小。
* @method setTileSize
- * @param {cc.Size} tileSize
+ * @param {Size} tileSize
+ * @example
+ * tiledMap.setTileSize(new cc.size(10, 10));
*/
setTileSize:function (tileSize) {
this._sgNode.setTileSize(tileSize);
},
/**
- * map orientation
+ * !#en map orientation.
+ * !#zh 获取地图方向。
* @method getMapOrientation
* @return {Number}
+ * @example
+ * var mapOrientation = tiledMap.getMapOrientation();
+ * cc.log("Map Orientation: " + mapOrientation);
*/
getMapOrientation:function () {
return this._sgNode.getMapOrientation();
},
/**
- * map orientation
+ * !#en map orientation.
+ * !#zh 设置地图方向。
* @method setMapOrientation
- * @param {Number} orientation
+ * @param {TiledMap.Orientation} orientation
+ * @example
+ * tiledMap.setMapOrientation(TiledMap.Orientation.ORTHO);
*/
setMapOrientation:function (orientation) {
this._sgNode.setMapOrientation(orientation);
},
/**
- * object groups
+ * !#en object groups.
+ * !#zh 获得物体层中所有对象。
* @method getObjectGroups
- * @return {Array}
+ * @return {Object[]}
+ * @example
+ * var objGroups = titledMap.getObjectGroups();
+ * for (var i = 0; i < objGroups.length; ++i) {
+ * cc.log("obj: " + objGroups[i]);
+ * }
*/
getObjectGroups:function () {
return this._sgNode.getObjectGroups();
},
/**
- * object groups
+ * !#en object groups.
+ * !#zh 设置物体层的所有对象。
* @method setObjectGroups
- * @param {Array} groups
+ * @param {Object[]} groups
+ * @example
+ * titledMap.setObjectGroups(groups);
*/
setObjectGroups:function (groups) {
this._sgNode.setObjectGroups(groups);
},
/**
- * Gets the map properties
+ * !#en Gets the map properties.
+ * !#zh 获取地图的属性。
* @method getProperties
- * @return {object}
+ * @return {Object[]}
+ * @example
+ * var properties = titledMap.getProperties();
+ * for (var i = 0; i < properties.length; ++i) {
+ * cc.log("Properties: " + properties[i]);
+ * }
*/
getProperties:function () {
return this._sgNode.getProperties();
},
/**
- * Set the map properties
+ * !#en Set the map properties.
+ * !#zh 设置地图的属性。
* @method setProperties
- * @param {object} properties
+ * @param {Object[]} properties
+ * @example
+ * titledMap.setProperties(properties);
*/
setProperties:function (properties) {
this._sgNode.setProperties(properties);
},
- /**
+ /*
* Initializes the instance of cc.TiledMap with tmxFile.
* The mapLoaded events will be emitted when the map is loaded.
* @method initWithTMXFile
@@ -309,7 +355,7 @@ var TiledMap = cc.Class({
this._tmxFile = tmxFile;
},
- /**
+ /*
* Initializes the instance of cc.TiledMap with tmxString.
* The mapLoaded events will be emitted when the map is loaded.
* @method initWithXML
@@ -350,9 +396,15 @@ var TiledMap = cc.Class({
},
/**
- * Return All layers array.
+ * !#en Return All layers array.
+ * !#zh 返回所有层级数组。
* @method allLayers
- * @returns {Array}
+ * @returns {Node[]}
+ * @example
+ * var layers = titledMap.allLayers();
+ * for (var i = 0; i < layers.length; ++i) {
+ * cc.log("Layers: " + layers[i]);
+ * }
*/
allLayers: function () {
var logicChildren = this.node.children;
@@ -369,10 +421,14 @@ var TiledMap = cc.Class({
},
/**
- * return the cc.TiledLayer for the specific layer
+ * !#en return the cc.TiledLayer for the specific layer.
+ * !#zh 通过层级名称获取层级。
* @method getLayer
* @param {String} layerName
- * @return {cc.TiledLayer}
+ * @return {TiledLayer}
+ * @example
+ * var layer = titledMap.getLayer("Player");
+ * cc.log(layer);
*/
getLayer:function (layerName) {
var logicChildren = this.node.children;
@@ -388,30 +444,42 @@ var TiledMap = cc.Class({
},
/**
- * Return the TMXObjectGroup for the specific group
+ * !#en Return the TMXObjectGroup for the specific group.
+ * !#zh 获取指定的 TMXObjectGroup。
* @method getObjectGroup
* @param {String} groupName
- * @return {cc.TMXObjectGroup}
+ * @return {TMXObjectGroup}
+ * @example
+ * var group = titledMap.getObjectGroup("Players");
+ * cc.log("ObjectGroup: " + group);
*/
getObjectGroup:function (groupName) {
return this._sgNode.getObjectGroup(groupName);
},
/**
- * Return the value for the specific property name
+ * !#en Return the value for the specific property name.
+ * !#zh 通过属性名称,获取指定的属性。
* @method getProperty
* @param {String} propertyName
* @return {String}
+ * @example
+ * var property = titledMap.getProperty("info");
+ * cc.log("Property: " + property);
*/
getProperty:function (propertyName) {
return this._sgNode.getProperty(propertyName);
},
/**
- * Return properties dictionary for tile GID
+ * !#en Return properties dictionary for tile GID.
+ * !#zh 通过 GID ,获取指定的属性。
* @method getPropertiesForGID
* @param {Number} GID
- * @return {object}
+ * @return {Object}
+ * @example
+ * var properties = titledMap.getPropertiesForGID(GID);
+ * cc.log("Properties: " + properties);
*/
getPropertiesForGID: function(GID) {
return this._sgNode.getPropertiesForGID(GID);
From cf77995a949931574282a4e7427d9dad2deff057 Mon Sep 17 00:00:00 2001
From: pandamicro
Date: Fri, 25 Mar 2016 20:49:01 +0800
Subject: [PATCH 09/12] Fix socket io variable name conflict in JSB
---
cocos2d/shaders/CCGLStateCache.js | 3 ++-
jsb/jsb-etc.js | 5 +++++
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/cocos2d/shaders/CCGLStateCache.js b/cocos2d/shaders/CCGLStateCache.js
index e7f401d421..ac5873ea2e 100644
--- a/cocos2d/shaders/CCGLStateCache.js
+++ b/cocos2d/shaders/CCGLStateCache.js
@@ -153,7 +153,8 @@ cc.gl.blendFuncForParticle = function(sfactor, dfactor) {
ctx.disable(ctx.BLEND);
} else {
ctx.enable(ctx.BLEND);
- //TODO need fix for WebGL
+ // TODO need fix for WebGL
+ // DO NOT TOUCH THIS, YOU MAY NOT BE ABLE TO FIX EVERYTHING
ctx.blendFuncSeparate(ctx.SRC_ALPHA, dfactor, sfactor, dfactor);
}
}
diff --git a/jsb/jsb-etc.js b/jsb/jsb-etc.js
index 35ca6d4a6f..8f21c36606 100644
--- a/jsb/jsb-etc.js
+++ b/jsb/jsb-etc.js
@@ -208,6 +208,11 @@ window.clearInterval = function (intervalId) {
};
window.clearTimeout = clearInterval;
+// SocketIO
+if (window.SocketIO) {
+ window.io = window.SocketIO;
+}
+
// ccsg
window._ccsg = {
Node: cc.Node,
From a9adcd63df7b61a8283ea0f4457638cfc97ce34b Mon Sep 17 00:00:00 2001
From: Jare Guo
Date: Fri, 25 Mar 2016 20:52:12 +0800
Subject: [PATCH 10/12] fix SpriteFrame.setTexture
---
cocos2d/core/sprites/CCSpriteFrame.js | 39 ++++++++++++++++-----------
1 file changed, 24 insertions(+), 15 deletions(-)
diff --git a/cocos2d/core/sprites/CCSpriteFrame.js b/cocos2d/core/sprites/CCSpriteFrame.js
index ee9e7f4e8f..ac666dceee 100644
--- a/cocos2d/core/sprites/CCSpriteFrame.js
+++ b/cocos2d/core/sprites/CCSpriteFrame.js
@@ -73,9 +73,6 @@ cc.SpriteFrame = cc.Class(/** @lends cc.SpriteFrame# */{
var texture = cc.textureCache.addImage(url);
this._refreshTexture(texture);
- if (this._textureLoaded) {
- this._checkRect(texture);
- }
}
}
}
@@ -241,12 +238,12 @@ cc.SpriteFrame = cc.Class(/** @lends cc.SpriteFrame# */{
* @param {Texture2D} texture
*/
_refreshTexture: function (texture) {
- if (this._texture !== texture) {
+ var self = this;
+ if (self._texture !== texture) {
var locLoaded = texture.isLoaded();
this._textureLoaded = locLoaded;
this._texture = texture;
- var self = this;
- var textureLoadedCallback = function () {
+ function textureLoadedCallback () {
self._textureLoaded = true;
if (self._rotated && cc._renderType === cc.game.RENDER_TYPE_CANVAS) {
var tempElement = texture.getHtmlElementObj();
@@ -260,25 +257,41 @@ cc.SpriteFrame = cc.Class(/** @lends cc.SpriteFrame# */{
self.setRect(cc.rect(0, 0, rect.width, rect.height));
}
var w = texture.width, h = texture.height;
- if (!self._rect) {
+
+ if (self._rect) {
+ self._checkRect(texture);
+ }
+ else {
self.setRect(cc.rect(0, 0, w, h));
}
+
if (!self._originalSize) {
self.setOriginalSize(cc.size(w, h));
}
+
if (!self._offset) {
self.setOffset(cc.v2(0, 0));
}
+
//dispatch 'load' event of cc.SpriteFrame
self.emit("load");
- };
+ }
- if (!locLoaded) {
- texture.once("load", textureLoadedCallback, this);
- } else {
+ if (locLoaded) {
textureLoadedCallback();
}
+ else {
+ texture.once("load", textureLoadedCallback);
+ }
}
+ //if (texture && texture.url && texture.isLoaded()) {
+ // if (self._rect) {
+ // self._checkRect(texture);
+ // }
+ // else {
+ // self.setRect(cc.rect(0, 0, texture.width, texture.height));
+ // }
+ //}
},
/**
@@ -357,10 +370,6 @@ cc.SpriteFrame = cc.Class(/** @lends cc.SpriteFrame# */{
//todo log error
}
- if (texture && texture.url && texture.isLoaded()) {
- this._checkRect(texture);
- }
-
return true;
},
From 6522aad698e31edb70f1e6d4df6b12b61ae1eafb Mon Sep 17 00:00:00 2001
From: zilongshanren
Date: Sat, 26 Mar 2016 10:40:15 +0800
Subject: [PATCH 11/12] fix editbox touch issue.
fix loadRes API issue
---
cocos2d/core/components/CCEditBox.js | 28 ++++++++++++++++++++++++++
cocos2d/core/editbox/CCSGEditBox.js | 11 ----------
cocos2d/core/load-pipeline/CCLoader.js | 6 ++----
3 files changed, 30 insertions(+), 15 deletions(-)
diff --git a/cocos2d/core/components/CCEditBox.js b/cocos2d/core/components/CCEditBox.js
index ed38bbe3f2..15d838bec4 100644
--- a/cocos2d/core/components/CCEditBox.js
+++ b/cocos2d/core/components/CCEditBox.js
@@ -455,6 +455,34 @@ var EditBox = cc.Class({
editBoxTextChanged: function(editBox, text) {
cc.Component.EventHandler.emitEvents(this.textChanged, text);
},
+
+ onLoad: function() {
+ this._super();
+
+ if (!CC_EDITOR) {
+ this._registerEvent();
+ }
+ },
+
+ _registerEvent: function () {
+ this.node.on(cc.Node.EventType.TOUCH_START, this._onTouchBegan, this);
+ this.node.on(cc.Node.EventType.TOUCH_END, this._onTouchEnded, this);
+ },
+
+ _onTouchBegan: function(event) {
+ if (this._sgNode) {
+ this._sgNode._onTouchBegan(event.touch);
+ }
+ event.stopPropagation();
+ },
+
+ _onTouchEnded: function(event) {
+ if (this._sgNode) {
+ this._sgNode._onTouchEnded();
+ }
+ event.stopPropagation();
+ }
+
});
cc.EditBox = module.exports = EditBox;
diff --git a/cocos2d/core/editbox/CCSGEditBox.js b/cocos2d/core/editbox/CCSGEditBox.js
index 8e640f9374..21fba5b8e7 100644
--- a/cocos2d/core/editbox/CCSGEditBox.js
+++ b/cocos2d/core/editbox/CCSGEditBox.js
@@ -698,23 +698,12 @@ _ccsg.EditBox = _ccsg.Node.extend({
this.setContentSize = this._updateEditBoxSize;
this.initWithSizeAndBackgroundSprite(size, normal9SpriteBg);
- this._registerTouchEvent();
this.scheduleOnce(function () {
editBoxImpl.registerClickEvent();
}, 0.01);
},
- _registerTouchEvent: function() {
- var touchListener = cc.EventListener.create({
- event: cc.EventListener.TOUCH_ONE_BY_ONE,
- swallowTouches: true,
- onTouchBegan: this._onTouchBegan.bind(this),
- onTouchEnded: this._onTouchEnded.bind(this),
- });
- cc.eventManager.addListener(touchListener, this);
- },
-
_onTouchBegan: function (touch, event) {
var touchPoint = touch.getLocation();
var bb = cc.rect(0,0, this._contentSize.width, this._contentSize.height);
diff --git a/cocos2d/core/load-pipeline/CCLoader.js b/cocos2d/core/load-pipeline/CCLoader.js
index 2820104939..419f7e7109 100644
--- a/cocos2d/core/load-pipeline/CCLoader.js
+++ b/cocos2d/core/load-pipeline/CCLoader.js
@@ -261,7 +261,6 @@ JS.mixin(cc.loader, {
* @method loadRes
* @param {String} url - Url of the target resource.
* The url is relative to the "resources" folder, extensions must be omitted.
- * @param {Function} [progressCallback] - Callback invoked when progression change. See {{#crossLink "Pipeline/onProgress:method"}}Pipeline.onProgress{{/crossLink}}.
* @param {Function} completeCallback - Callback invoked when the resource loaded.
* @param {Error} completeCallback.error - The error info or null if loaded successfully.
* @param {Object} completeCallback.resource - The loaded resource if it can be found otherwise returns null.
@@ -277,7 +276,7 @@ JS.mixin(cc.loader, {
* cc.log('Result should be a sprite frame: ' + ( spriteFrame instanceof cc.SpriteFrame));
* });
*/
- loadRes: function (url, progressCallback, completeCallback) {
+ loadRes: function (url, completeCallback) {
var uuid = this._getResUuid(url);
if (uuid) {
this.load(
@@ -286,7 +285,6 @@ JS.mixin(cc.loader, {
type: 'uuid',
uuid: uuid
},
- progressCallback,
completeCallback
);
}
@@ -368,4 +366,4 @@ JS.mixin(cc.loader, {
}
});
-module.exports = cc.loader;
\ No newline at end of file
+module.exports = cc.loader;
From 325175ec53c514ed26c6fe2b35a1b27fa752edcc Mon Sep 17 00:00:00 2001
From: knoxHuang <821686174@qq.com>
Date: Mon, 28 Mar 2016 10:58:13 +0800
Subject: [PATCH 12/12] fix tile map api error
---
cocos2d/tilemap/CCTMXObjectGroup.js | 9 ++++-----
cocos2d/tilemap/CCTiledLayer.js | 8 ++++----
cocos2d/tilemap/CCTiledMap.js | 20 ++++++++++----------
3 files changed, 18 insertions(+), 19 deletions(-)
diff --git a/cocos2d/tilemap/CCTMXObjectGroup.js b/cocos2d/tilemap/CCTMXObjectGroup.js
index 352167c511..a4cfeb0c89 100644
--- a/cocos2d/tilemap/CCTMXObjectGroup.js
+++ b/cocos2d/tilemap/CCTMXObjectGroup.js
@@ -79,7 +79,7 @@ cc.TMXObjectGroup = cc._Class.extend(/** @lends cc.TMXObjectGroup# */{
/**
* !#en List of properties stored in a dictionary.
- * !#zh 获取存储在字典中的属性队列。
+ * !#zh 以映射的形式获取属性列表。
* @method getProperties
* @return {Array}
* @example
@@ -91,7 +91,7 @@ cc.TMXObjectGroup = cc._Class.extend(/** @lends cc.TMXObjectGroup# */{
/**
* !#en List of properties stored in a dictionary.
- * !#zh 设置属性队列。
+ * !#zh 设置属性列表。
* @method setProperties
* @param {Object} Var
* @example
@@ -147,10 +147,9 @@ cc.TMXObjectGroup = cc._Class.extend(/** @lends cc.TMXObjectGroup# */{
/**
* !#en
- * Return the dictionary for the specific object name.
+ * Return the object for the specific object name.
* It will return the 1st object found on the array for the given name.
- * !#zh 获取指定对象名的字典。
- * 它将返回的是符号指定名字的数组中第一个对象。
+ * !#zh 获取指定的对象。
* @method getObject
* @param {String} objectName
* @return {Object|Null}
diff --git a/cocos2d/tilemap/CCTiledLayer.js b/cocos2d/tilemap/CCTiledLayer.js
index 072c724cb7..6b78ecacb4 100644
--- a/cocos2d/tilemap/CCTiledLayer.js
+++ b/cocos2d/tilemap/CCTiledLayer.js
@@ -140,7 +140,7 @@ var TiledLayer = cc.Class({
/**
* !#en Returns the position in pixels of a given tile coordinate.
- * !#zh 获取指定坐标的位置(以点为单位)。
+ * !#zh 获取指定 ttile 的像素坐标。
* @method getPositionAt
* @param {Vec2|Number} pos position or x
* @param {Number} [y]
@@ -234,7 +234,7 @@ var TiledLayer = cc.Class({
* This method requires the the tile map has not been previously released (eg. don't call layer.releaseMap())
* !#zh
* 通过给定的 tile 坐标、flags(可选)返回 tile 的 GID.
- * 如果它返回 0,则表示该文件为空。
+ * 如果它返回 0,则表示该 tile 为空。
* 该方法要求 tile 地图之前没有被释放过(如:没有调用过layer.releaseMap()).
* @method getTileGIDAt
* @param {Vec2|Number} pos or x
@@ -304,7 +304,7 @@ var TiledLayer = cc.Class({
/**
* !#en Sets the untransformed size of the _ccsg.TMXLayer.
- * !#zh 设置不转换节点的大小。
+ * !#zh 设置未转换的 layer 大小。
* @method setContentSize
* @param {Size|Number} size The untransformed size of the _ccsg.TMXLayer or The untransformed size's width of the TMXLayer.
* @param {Number} [height] The untransformed size's height of the _ccsg.TMXLayer.
@@ -499,7 +499,7 @@ var TiledLayer = cc.Class({
/**
* !#en properties from the layer. They can be added using Tiled.
- * !#zh 获取 layer 的属性,可以被当作 Tile 添加。
+ * !#zh 获取 layer 的属性,可以使用 Tiled 编辑器添加属性。
* @method getProperties
* @return {Array}
* @example
diff --git a/cocos2d/tilemap/CCTiledMap.js b/cocos2d/tilemap/CCTiledMap.js
index cc1823ba0c..f9c7610fec 100644
--- a/cocos2d/tilemap/CCTiledMap.js
+++ b/cocos2d/tilemap/CCTiledMap.js
@@ -25,7 +25,7 @@
/**
* !#en The orientation of tiled map.
- * !#zh Tiled Map 地图定向。
+ * !#zh Tiled Map 地图方向。
* @enum TiledMap.Orientation
* @static
*/
@@ -151,7 +151,7 @@ var TileFlag = cc.Enum({
/**
* !#en Renders a TMX Tile Map in the scene.
- * !#zh 渲染一个 tmx 地图编辑器导出 Tile Map 的场景。
+ * !#zh 在场景中渲染一个 tmx 格式的 Tile Map。
* @class TiledMap
* @extends Component
*/
@@ -218,7 +218,7 @@ var TiledMap = cc.Class({
/**
* !#en Gets the map size.
- * !#zh 获取地图背景的大小。
+ * !#zh 获取地图大小。
* @method getMapSize
* @return {Size}
* @example
@@ -231,7 +231,7 @@ var TiledMap = cc.Class({
/**
* !#en Set the map size.
- * !#zh 设置地图背景的大小。
+ * !#zh 设置地图大小。
* @method setMapSize
* @param {Size} mapSize
* @example
@@ -243,7 +243,7 @@ var TiledMap = cc.Class({
/**
* !#en Gets the tile size.
- * !#zh 获取地图背景中砖块元素的大小。
+ * !#zh 获取地图背景中 tile 元素的大小。
* @method getTileSize
* @return {Size}
* @example
@@ -256,7 +256,7 @@ var TiledMap = cc.Class({
/**
* !#en Set the tile size.
- * !#zh 设置地图背景中砖块元素的大小。
+ * !#zh 设置地图背景中 tile 元素的大小。
* @method setTileSize
* @param {Size} tileSize
* @example
@@ -293,7 +293,7 @@ var TiledMap = cc.Class({
/**
* !#en object groups.
- * !#zh 获得物体层中所有对象。
+ * !#zh 获取所有的对象层。
* @method getObjectGroups
* @return {Object[]}
* @example
@@ -308,7 +308,7 @@ var TiledMap = cc.Class({
/**
* !#en object groups.
- * !#zh 设置物体层的所有对象。
+ * !#zh 设置所有的对象层。
* @method setObjectGroups
* @param {Object[]} groups
* @example
@@ -397,7 +397,7 @@ var TiledMap = cc.Class({
/**
* !#en Return All layers array.
- * !#zh 返回所有层级数组。
+ * !#zh 返回包含所有 layer 的数组。
* @method allLayers
* @returns {Node[]}
* @example
@@ -422,7 +422,7 @@ var TiledMap = cc.Class({
/**
* !#en return the cc.TiledLayer for the specific layer.
- * !#zh 通过层级名称获取层级。
+ * !#zh 获取指定名称的 layer。
* @method getLayer
* @param {String} layerName
* @return {TiledLayer}