diff --git a/CCBoot.js b/CCBoot.js
index e09b238171..2e58df600d 100644
--- a/CCBoot.js
+++ b/CCBoot.js
@@ -58,7 +58,7 @@ _p = null;
* @name cc.ENGINE_VERSION
*/
var engineVersion;
-engineVersion = '0.8.0-beta.7';
+engineVersion = '0.8.0-beta.9';
window['CocosEngine'] = cc.ENGINE_VERSION = engineVersion;
/**
diff --git a/README.mdown b/README.mdown
index edf6964a37..bb9fdb495a 100644
--- a/README.mdown
+++ b/README.mdown
@@ -1,4 +1,4 @@
-Cocos2d-html5
+Cocos Creator Game Engine
==================
[Cocos2d-html5][1] is a cross-platform 2D game engine written in Javascript, based on [Cocos2d-X][2] and licensed under MIT.
diff --git a/cocos2d/actions/CCAction.js b/cocos2d/actions/CCAction.js
index 1c7b8f9fd7..bbb268309c 100644
--- a/cocos2d/actions/CCAction.js
+++ b/cocos2d/actions/CCAction.js
@@ -29,7 +29,8 @@
*/
/**
- * Base class cc.Action for action classes.
+ * !#en Base class cc.Action for action classes.
+ * !#zh Action 类是所有动作类型的基类。
* @class Action
*/
cc.Action = cc._Class.extend({
@@ -43,8 +44,10 @@ cc.Action = cc._Class.extend({
},
/**
+ * !#en
* to copy object with deep copy.
* returns a clone of action.
+ * !#zh 返回一个克隆的动作。
* @method clone
* @return {Action}
*/
@@ -57,7 +60,9 @@ cc.Action = cc._Class.extend({
},
/**
+ * !#en
* return true if the action has finished.
+ * !#zh 如果动作已完成就返回 true。
* @method isDone
* @return {Boolean}
*/
@@ -87,7 +92,8 @@ cc.Action = cc._Class.extend({
},
/**
- * get the target.
+ * !#en get the target.
+ * !#zh 获取当前目标节点。
* @method getTarget
* @return {Node}
*/
@@ -96,7 +102,8 @@ cc.Action = cc._Class.extend({
},
/**
- * The action will modify the target properties.
+ * !#en The action will modify the target properties.
+ * !#zh 设置目标节点。
* @method setTarget
* @param {Node} target
*/
@@ -105,7 +112,8 @@ cc.Action = cc._Class.extend({
},
/**
- * get the original target.
+ * !#en get the original target.
+ * !#zh 获取原始目标节点。
* @method getOriginalTarget
* @return {Node}
*/
@@ -121,7 +129,8 @@ cc.Action = cc._Class.extend({
},
/**
- * get tag number.
+ * !#en get tag number.
+ * !#zh 获取用于识别动作的标签。
* @method getTag
* @return {Number}
*/
@@ -130,7 +139,8 @@ cc.Action = cc._Class.extend({
},
/**
- * set tag number.
+ * !#en set tag number.
+ * !#zh 设置标签,用于识别动作。
* @method setTag
* @param {Number} tag
*/
@@ -151,21 +161,27 @@ cc.Action = cc._Class.extend({
}
});
-/** Default Action tag
+/**
+ * !#en Default Action tag.
+ * !#zh 默认动作标签。
+ * @property TAG_INVALID
* @constant
+ * @static
* @type {Number}
- * @default
+ * @default -1
*/
cc.Action.TAG_INVALID = -1;
/**
+ * !#en
* Base class actions that do have a finite time duration.
* Possible actions:
* - An action with a duration of 0 seconds.
* - An action with a duration of 35.5 seconds.
*
* Infinite time actions are valid
+ * !#zh 有限时间动作,这种动作拥有时长 duration 属性。
* @class FiniteTimeAction
* @extends Action
*/
@@ -179,7 +195,8 @@ cc.FiniteTimeAction = cc.Action.extend({
},
/**
- * get duration of the action. (seconds)
+ * !#en get duration of the action. (seconds).
+ * !#zh 获取动作以秒为单位的持续时间。
* @method getDuration
* @return {Number}
*/
@@ -188,7 +205,8 @@ cc.FiniteTimeAction = cc.Action.extend({
},
/**
- * set duration of the action. (seconds)
+ * !#en set duration of the action. (seconds).
+ * !#zh 设置动作以秒为单位的持续时间。
* @method setDuration
* @param {Number} duration
*/
@@ -197,11 +215,13 @@ cc.FiniteTimeAction = cc.Action.extend({
},
/**
+ * !#en
* Returns a reversed action.
* For example:
* - The action will be x coordinates of 0 move to 100.
* - The reversed action will be x of 100 move to 0.
* - Will be rewritten
+ * !#zh 返回一个新的动作,执行与原动作完全相反的动作。
* @method reverse
* @return {Null}
*/
@@ -211,8 +231,10 @@ cc.FiniteTimeAction = cc.Action.extend({
},
/**
+ * !#en
* to copy object with deep copy.
* returns a clone of action.
+ * !#zh 返回一个克隆的动作。
* @method clone
* @return {FiniteTimeAction}
*/
@@ -249,7 +271,7 @@ cc.Speed = cc.Action.extend({
action && this.initWithAction(action, speed);
},
- /**
+ /*
* Gets the current running speed.
* Will get a percentage number, compared to the original speed.
*
@@ -260,7 +282,7 @@ cc.Speed = cc.Action.extend({
return this._speed;
},
- /**
+ /*
* alter the speed of the inner function in runtime.
* @method setSpeed
* @param {Number} speed
@@ -269,7 +291,7 @@ cc.Speed = cc.Action.extend({
this._speed = speed;
},
- /**
+ /*
* initializes the action.
* @method initWithAction
* @param {ActionInterval} action
@@ -313,7 +335,7 @@ cc.Speed = cc.Action.extend({
return new cc.Speed(this._innerAction.reverse(), this._speed);
},
- /**
+ /*
* Set inner Action.
* @method setInnerAction
* @param {ActionInterval} action
@@ -324,7 +346,7 @@ cc.Speed = cc.Action.extend({
}
},
- /**
+ /*
* Get inner Action.
* @method getInnerAction
* @return {ActionInterval}
@@ -339,16 +361,21 @@ cc.Speed = cc.Action.extend({
*/
/**
+ * !#en
* Creates the speed action which changes the speed of an action, making it take longer (speed > 1)
* or less (speed < 1) time.
* Useful to simulate 'slow motion' or 'fast forward' effect.
- *
+ * !#zh 修改目标动作的速率。
* @warning This action can't be Sequenceable because it is not an cc.IntervalAction
*
* @method speed
* @param {ActionInterval} action
* @param {Number} speed
* @return {Action}
+ * @example
+ * // change the target action speed;
+ * var action = cc.scaleTo(0.2, 1, 0.6);
+ * var newAction = cc.speed(action, 0.5);
*/
cc.speed = function (action, speed) {
return new cc.Speed(action, speed);
@@ -400,7 +427,7 @@ cc.Follow = cc.Action.extend({
topBoundary:0.0,
bottomBoundary:0.0,
- /**
+ /*
* Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
* creates the action with a set boundary.
* creates the action with no boundary set.
@@ -528,8 +555,8 @@ cc.Follow = cc.Action.extend({
});
/**
- * Create a follow action which makes its target follows another node.
- *
+ * !#en Create a follow action which makes its target follows another node.
+ * !#zh 追踪目标节点的位置。
* @method follow
* @param {Node} followedNode
* @param {Rect} rect
diff --git a/cocos2d/actions/CCActionCatmullRom.js b/cocos2d/actions/CCActionCatmullRom.js
index d7ee983e17..123f62a528 100644
--- a/cocos2d/actions/CCActionCatmullRom.js
+++ b/cocos2d/actions/CCActionCatmullRom.js
@@ -268,8 +268,8 @@ cc.CardinalSplineTo = cc.ActionInterval.extend({
});
/**
- * creates an action with a Cardinal Spline array of points and tension.
- *
+ * !#en Creates an action with a Cardinal Spline array of points and tension.
+ * !#zh 按基数样条曲线轨迹移动到目标位置。
* @method cardinalSplineTo
* @param {Number} duration
* @param {Array} points array of control points
@@ -378,8 +378,8 @@ cc.CardinalSplineBy = cc.CardinalSplineTo.extend({
});
/**
- * creates an action with a Cardinal Spline array of points and tension.
- *
+ * !#en Creates an action with a Cardinal Spline array of points and tension.
+ * !#zh 按基数样条曲线轨迹移动指定的距离。
* @method cardinalSplineBy
* @param {Number} duration
* @param {Array} points
@@ -430,8 +430,8 @@ cc.CatmullRomTo = cc.CardinalSplineTo.extend({
});
/**
- * creates an action with a Cardinal Spline array of points and tension.
- *
+ * !#en Creates an action with a Cardinal Spline array of points and tension.
+ * !#zh 按 Catmull Rom 样条曲线轨迹移动到目标位置。
* @method catmullRomTo
* @param {Number} dt
* @param {Array} points
@@ -485,7 +485,8 @@ cc.CatmullRomBy = cc.CardinalSplineBy.extend({
});
/**
- * Creates an action with a Cardinal Spline array of points and tension
+ * !#en Creates an action with a Cardinal Spline array of points and tension.
+ * !#zh 按 Catmull Rom 样条曲线轨迹移动指定的距离。
* @method catmullRomBy
* @param {Number} dt
* @param {Array} points
diff --git a/cocos2d/actions/CCActionEase.js b/cocos2d/actions/CCActionEase.js
index 0777104624..fe147af550 100644
--- a/cocos2d/actions/CCActionEase.js
+++ b/cocos2d/actions/CCActionEase.js
@@ -29,7 +29,8 @@
*/
/**
- * Base class for Easing actions
+ * !#en Base class for Easing actions.
+ * !#zh 所有缓动动作基类,用于修饰 ActionInterval。
* @class ActionEase
* @extends ActionInterval
* @param {ActionInterval} action
@@ -98,8 +99,8 @@ cc.actionEase = function (action) {
};
/**
- * Base class for Easing actions with rate parameters
- *
+ * !#en Base class for Easing actions with rate parameters
+ * !#zh 拥有速率属性的缓动动作基类。
* @class EaseRateAction
* @extends ActionEase
* @param {ActionInterval} action
@@ -191,9 +192,10 @@ cc.EaseIn = cc.EaseRateAction.extend({
});
/**
+ * !#en
* Creates the action easing object with the rate parameter.
* From slow to fast.
- *
+ * !#zh 创建 easeIn 缓动对象,由慢到快。
* @method easeIn
* @param {Number} rate
* @return {Object}
@@ -241,9 +243,10 @@ cc.EaseOut = cc.EaseRateAction.extend({
});
/**
+ * !#en
* Creates the action easing object with the rate parameter.
* From fast to slow.
- *
+ * !#zh 创建 easeOut 缓动对象,由快到慢。
* @method easeOut
* @param {Number} rate
* @return {Object}
@@ -295,8 +298,10 @@ cc.EaseInOut = cc.EaseRateAction.extend({
});
/**
+ * !#en
* Creates the action easing object with the rate parameter.
* Slow to fast then to slow.
+ * !#zh 创建 easeInOut 缓动对象,慢到快,然后慢。
* @method easeInOut
* @param {Number} rate
* @return {Object}
@@ -359,9 +364,14 @@ cc._easeExponentialInObj = {
};
/**
+ * !#en
* Creates the action easing object with the rate parameter.
* Reference easeInExpo:
* http://www.zhihu.com/question/21981571/answer/19925418
+ * !#zh
+ * 创建 easeExponentialIn 缓动对象。
+ * EaseExponentialIn 是按指数函数缓动进入的动作。
+ * 参考 easeInExpo:http://www.zhihu.com/question/21981571/answer/19925418
* @method easeExponentialIn
* @return {Object}
* @example
@@ -410,9 +420,14 @@ cc._easeExponentialOutObj = {
};
/**
- * creates the action easing object.
+ * !#en
+ * Creates the action easing object.
* Reference easeOutExpo:
* http://www.zhihu.com/question/21981571/answer/19925418
+ * !#zh
+ * 创建 easeExponentialOut 缓动对象。
+ * EaseExponentialOut 是按指数函数缓动退出的动作。
+ * 参考 easeOutExpo:http://www.zhihu.com/question/21981571/answer/19925418
* @method easeExponentialOut
* @return {Object}
* @example
@@ -476,9 +491,14 @@ cc._easeExponentialInOutObj = {
};
/**
- * creates an EaseExponentialInOut action easing object.
+ * !#en
+ * Creates an EaseExponentialInOut action easing object.
* Reference easeInOutExpo:
* http://www.zhihu.com/question/21981571/answer/19925418
+ * !#zh
+ * 创建 easeExponentialInOut 缓动对象。
+ * EaseExponentialInOut 是按指数函数缓动进入并退出的动作。
+ * 参考 easeInOutExpo:http://www.zhihu.com/question/21981571/answer/19925418
* @method easeExponentialInOut
* @return {Object}
* @example
@@ -527,9 +547,14 @@ cc._easeSineInObj = {
}
};
/**
- * creates an EaseSineIn action.
+ * !#en
+ * Creates an EaseSineIn action.
* Reference easeInSine:
* http://www.zhihu.com/question/21981571/answer/19925418
+ * !#zh
+ * 创建 EaseSineIn 缓动对象。
+ * EaseSineIn 是按正弦函数缓动进入的动作。
+ * 参考 easeInSine:http://www.zhihu.com/question/21981571/answer/19925418
* @method easeSineIn
* @return {Object}
* @example
@@ -579,9 +604,14 @@ cc._easeSineOutObj = {
};
/**
+ * !#en
* Creates an EaseSineOut action easing object.
* Reference easeOutSine:
* http://www.zhihu.com/question/21981571/answer/19925418
+ * !#zh
+ * 创建 EaseSineOut 缓动对象。
+ * EaseSineIn 是按正弦函数缓动退出的动作。
+ * 参考 easeOutSine:http://www.zhihu.com/question/21981571/answer/19925418
* @method easeSineOut
* @return {Object}
* @example
@@ -631,9 +661,14 @@ cc._easeSineInOutObj = {
};
/**
- * creates the action easing object.
+ * !#en
+ * Creates the action easing object.
* Reference easeInOutSine:
* http://www.zhihu.com/question/21981571/answer/19925418
+ * !#zh
+ * 创建 easeSineInOut 缓动对象。
+ * EaseSineIn 是按正弦函数缓动进入并退出的动作。
+ * 参考 easeInOutSine:http://www.zhihu.com/question/21981571/answer/19925418
* @method easeSineInOut
* @return {Object}
* @example
@@ -645,11 +680,12 @@ cc.easeSineInOut = function(){
};
/**
- * Ease Elastic abstract class.
+ * !#en Ease Elastic abstract class.
+ * !#zh 弹性缓动动作基类。
* @class EaseElastic
* @extends ActionEase
* @param {ActionInterval} action
- * @param {Number} [period=0.3]
+ * @param {Number} period
*/
cc.EaseElastic = cc.ActionEase.extend({
_period: 0.3,
@@ -755,11 +791,16 @@ cc._easeElasticInObj = {
};
/**
+ * !#en
* Creates the action easing obejct with the period in radians (default is 0.3).
* Reference easeInElastic:
* http://www.zhihu.com/question/21981571/answer/19925418
+ * !#zh
+ * 创建 easeElasticIn 缓动对象。
+ * EaseElasticIn 是按弹性曲线缓动进入的动作。
+ * 参数 easeInElastic:http://www.zhihu.com/question/21981571/answer/19925418
* @method easeElasticIn
- * @param {Number} [period=0.3]
+ * @param {Number} period
* @return {Object}
* @example
* // example
@@ -830,11 +871,16 @@ cc._easeElasticOutObj = {
}
};
/**
+ * !#en
* Creates the action easing object with the period in radians (default is 0.3).
* Reference easeOutElastic:
* http://www.zhihu.com/question/21981571/answer/19925418
+ * !#zh
+ * 创建 easeElasticOut 缓动对象。
+ * EaseElasticOut 是按弹性曲线缓动退出的动作。
+ * 参考 easeOutElastic:http://www.zhihu.com/question/21981571/answer/19925418
* @method easeElasticOut
- * @param {Number} [period=0.3]
+ * @param {Number} period
* @return {Object}
* @example
* // example
@@ -901,11 +947,16 @@ cc.EaseElasticInOut = cc.EaseElastic.extend({
});
/**
+ * !#en
* Creates the action easing object with the period in radians (default is 0.3).
* Reference easeInOutElastic:
* http://www.zhihu.com/question/21981571/answer/19925418
+ * !#zh
+ * 创建 easeElasticInOut 缓动对象。
+ * EaseElasticInOut 是按弹性曲线缓动进入并退出的动作。
+ * 参考 easeInOutElastic:http://www.zhihu.com/question/21981571/answer/19925418
* @method easeElasticInOut
- * @param {Number} [period=0.3]
+ * @param {Number} period
* @return {Object}
* @example
* // example
@@ -940,8 +991,8 @@ cc.easeElasticInOut = function (period) {
};
/**
- * cc.EaseBounce abstract class.
- *
+ * !#en cc.EaseBounce abstract class.
+ * !#zh 反弹缓动动作基类。
* @class EaseBounce
* @extends ActionEase
*/
@@ -1034,8 +1085,12 @@ cc._easeBounceInObj = {
};
/**
+ * !#en
* Creates the action easing object.
* Eased bounce effect at the beginning.
+ * !#zh
+ * 创建 easeBounceIn 缓动对象。
+ * EaseBounceIn 是按弹跳动作缓动进入的动作。
* @method easeBounceIn
* @return {Object}
* @example
@@ -1085,8 +1140,12 @@ cc._easeBounceOutObj = {
};
/**
+ * !#en
* Creates the action easing object.
* Eased bounce effect at the ending.
+ * !#zh
+ * 创建 easeBounceOut 缓动对象。
+ * EaseBounceOut 是按弹跳动作缓动退出的动作。
* @method easeBounceOut
* @return {Object}
* @example
@@ -1149,8 +1208,12 @@ cc._easeBounceInOutObj = {
};
/**
+ * !#en
* Creates the action easing object.
* Eased bounce effect at the begining and ending.
+ * !#zh
+ * 创建 easeBounceInOut 缓动对象。
+ * EaseBounceInOut 是按弹跳动作缓动进入并退出的动作。
* @method easeBounceInOut
* @return {Object}
* @example
@@ -1202,8 +1265,12 @@ cc._easeBackInObj = {
};
/**
+ * !#en
* Creates the action easing object.
* In the opposite direction to move slowly, and then accelerated to the right direction.
+ * !#zh
+ * 创建 easeBackIn 缓动对象。
+ * easeBackIn 是在相反的方向缓慢移动,然后加速到正确的方向。
* @method easeBackIn
* @return {Object}
* @example
@@ -1256,8 +1323,12 @@ cc._easeBackOutObj = {
};
/**
+ * !#en
* Creates the action easing object.
* Fast moving more than the finish, and then slowly back to the finish.
+ * !#zh
+ * 创建 easeBackOut 缓动对象。
+ * easeBackOut 快速移动超出目标,然后慢慢回到目标点。
* @method easeBackOut
* @return {Object}
* @example
@@ -1320,8 +1391,11 @@ cc._easeBackInOutObj = {
};
/**
+ * !#en
* Creates the action easing object.
* Begining of cc.EaseBackIn. Ending of cc.EaseBackOut.
+ * !#zh
+ * 创建 easeBackInOut 缓动对象。
* @method easeBackInOut
* @return {Object}
* @example
@@ -1399,9 +1473,13 @@ cc.EaseBezierAction = cc.ActionEase.extend({
});
/**
+ * !#en
* Creates the action easing object.
* Into the 4 reference point.
* To calculate the motion curve.
+ * !#zh
+ * 创建 easeBezierAction 缓动对象。
+ * EaseBezierAction 是按贝塞尔曲线缓动的动作。
* @method easeBezierAction
* @param {Number} p0 The first bezier parameter
* @param {Number} p1 The second bezier parameter
@@ -1465,9 +1543,14 @@ cc._easeQuadraticActionIn = {
};
/**
+ * !#en
* Creates the action easing object.
* Reference easeInQuad:
* http://www.zhihu.com/question/21981571/answer/19925418
+ * !#zh
+ * 创建 easeQuadraticActionIn 缓动对象。
+ * EaseQuadraticIn是按二次函数缓动进入的动作。
+ * 参考 easeInQuad:http://www.zhihu.com/question/21981571/answer/19925418
* @method easeQuadraticActionIn
* @returns {Object}
* @example
@@ -1518,9 +1601,14 @@ cc._easeQuadraticActionOut = {
}
};
/**
+ * !#en
* Creates the action easing object.
* Reference easeOutQuad:
* http://www.zhihu.com/question/21981571/answer/19925418
+ * !#zh
+ * 创建 easeQuadraticActionOut 缓动对象。
+ * EaseQuadraticOut 是按二次函数缓动退出的动作。
+ * 参考 easeOutQuad:http://www.zhihu.com/question/21981571/answer/19925418
* @method easeQuadraticActionOut
* @returns {Object}
* @example
@@ -1579,9 +1667,14 @@ cc._easeQuadraticActionInOut = {
};
/**
+ * !#en
* Creates the action easing object.
* Reference easeInOutQuad:
* http://www.zhihu.com/question/21981571/answer/19925418
+ * !#zh
+ * 创建 easeQuadraticActionInOut 缓动对象。
+ * EaseQuadraticInOut 是按二次函数缓动进入并退出的动作。
+ * 参考 easeInOutQuad:http://www.zhihu.com/question/21981571/answer/19925418
* @method easeQuadraticActionInOut
* @returns {Object}
* @example
@@ -1631,9 +1724,14 @@ cc._easeQuarticActionIn = {
}
};
/**
+ * !#en
* Creates the action easing object.
* Reference easeIntQuart:
* http://www.zhihu.com/question/21981571/answer/19925418
+ * !#zh
+ * 创建 easeQuarticActionIn 缓动对象。
+ * EaseQuarticIn 是按四次函数缓动进入的动作。
+ * 参考 easeIntQuart:http://www.zhihu.com/question/21981571/answer/19925418
* @method easeQuarticActionIn
* @returns {Object}
* @example
@@ -1685,9 +1783,14 @@ cc._easeQuarticActionOut = {
};
/**
+ * !#en
* Creates the action easing object.
* Reference easeOutQuart:
* http://www.zhihu.com/question/21981571/answer/19925418
+ * !#zh
+ * 创建 easeQuarticActionOut 缓动对象。
+ * EaseQuarticOut 是按四次函数缓动退出的动作。
+ * 参考 easeOutQuart:http://www.zhihu.com/question/21981571/answer/19925418
* @method easeQuarticActionOut
* @returns {Object}
* @example
@@ -1741,9 +1844,14 @@ cc._easeQuarticActionInOut = {
}
};
/**
+ * !#en
* Creates the action easing object.
* Reference easeInOutQuart:
* http://www.zhihu.com/question/21981571/answer/19925418
+ * !#zh
+ * 创建 easeQuarticActionInOut 缓动对象。
+ * EaseQuarticInOut 是按四次函数缓动进入并退出的动作。
+ * 参考 easeInOutQuart:http://www.zhihu.com/question/21981571/answer/19925418
* @method easeQuarticActionInOut
* @returns {Object}
*/
@@ -1791,9 +1899,14 @@ cc._easeQuinticActionIn = {
};
/**
+ * !#en
* Creates the action easing object.
* Reference easeInQuint:
* http://www.zhihu.com/question/21981571/answer/19925418
+ * !#zh
+ * 创建 easeQuinticActionIn 缓动对象。
+ * EaseQuinticIn 是按五次函数缓动进的动作。
+ * 参考 easeInQuint:http://www.zhihu.com/question/21981571/answer/19925418
* @method easeQuinticActionIn
* @returns {Object}
* @example
@@ -1845,9 +1958,14 @@ cc._easeQuinticActionOut = {
};
/**
+ * !#en
* Creates the action easing object.
* Reference easeOutQuint:
* http://www.zhihu.com/question/21981571/answer/19925418
+ * !#zh
+ * 创建 easeQuinticActionOut 缓动对象。
+ * EaseQuinticOut 是按五次函数缓动退出的动作
+ * 参考 easeOutQuint:http://www.zhihu.com/question/21981571/answer/19925418
* @method easeQuinticActionOut
* @returns {Object}
* @example
@@ -1902,9 +2020,14 @@ cc._easeQuinticActionInOut = {
};
/**
+ * !#en
* Creates the action easing object.
* Reference easeInOutQuint:
* http://www.zhihu.com/question/21981571/answer/19925418
+ * !#zh
+ * 创建 easeQuinticActionInOut 缓动对象。
+ * EaseQuinticInOut是按五次函数缓动进入并退出的动作。
+ * 参考 easeInOutQuint:http://www.zhihu.com/question/21981571/answer/19925418
* @method easeQuinticActionInOut
* @returns {Object}
* @example
@@ -1955,9 +2078,14 @@ cc._easeCircleActionIn = {
};
/**
+ * !#en
* Creates the action easing object.
* Reference easeInCirc:
* http://www.zhihu.com/question/21981571/answer/19925418
+ * !#zh
+ * 创建 easeCircleActionIn 缓动对象。
+ * EaseCircleIn是按圆形曲线缓动进入的动作。
+ * 参考 easeInCirc:http://www.zhihu.com/question/21981571/answer/19925418
* @method easeCircleActionIn
* @returns {Object}
* @example
@@ -2009,9 +2137,14 @@ cc._easeCircleActionOut = {
};
/**
+ * !#en
* Creates the action easing object.
* Reference easeOutCirc:
* http://www.zhihu.com/question/21981571/answer/19925418
+ * !#zh
+ * 创建 easeCircleActionOut 缓动对象。
+ * EaseCircleOut是按圆形曲线缓动退出的动作。
+ * 参考 easeOutCirc:http://www.zhihu.com/question/21981571/answer/19925418
* @method easeCircleActionOut
* @returns {Object}
* @exampple
@@ -2066,9 +2199,14 @@ cc._easeCircleActionInOut = {
};
/**
+ * !#en
* Creates the action easing object.
* Reference easeInOutCirc:
* http://www.zhihu.com/question/21981571/answer/19925418
+ * !#zh
+ * 创建 easeCircleActionInOut 缓动对象。
+ * EaseCircleInOut 是按圆形曲线缓动进入并退出的动作。
+ * 参考 easeInOutCirc:http://www.zhihu.com/question/21981571/answer/19925418
* @method easeCircleActionInOut
* @returns {Object}
* @example
@@ -2119,9 +2257,14 @@ cc._easeCubicActionIn = {
};
/**
+ * !#en
* Creates the action easing object.
* Reference easeInCubic:
* http://www.zhihu.com/question/21981571/answer/19925418
+ * !#zh
+ * 创建 easeCubicActionIn 缓动对象。
+ * EaseCubicIn 是按三次函数缓动进入的动作。
+ * 参考 easeInCubic:http://www.zhihu.com/question/21981571/answer/19925418
* @method easeCubicActionIn
* @returns {Object}
* @example
@@ -2173,9 +2316,14 @@ cc._easeCubicActionOut = {
};
/**
+ * !#en
* Creates the action easing object.
* Reference easeOutCubic:
* http://www.zhihu.com/question/21981571/answer/19925418
+ * !#zh
+ * 创建 easeCubicActionOut 缓动对象。
+ * EaseCubicOut 是按三次函数缓动退出的动作。
+ * 参考 easeOutCubic:http://www.zhihu.com/question/21981571/answer/19925418
* @method easeCubicActionOut
* @returns {Object}
* @example
@@ -2230,9 +2378,14 @@ cc._easeCubicActionInOut = {
};
/**
+ * !#en
* Creates the action easing object.
* Reference easeInOutCubic:
* http://www.zhihu.com/question/21981571/answer/19925418
+ * !#zh
+ * 创建 easeCubicActionInOut 缓动对象。
+ * EaseCubicInOut是按三次函数缓动进入并退出的动作。
+ * 参考 easeInOutCubic:http://www.zhihu.com/question/21981571/answer/19925418
* @method easeCubicActionInOut
* @returns {Object}
*/
diff --git a/cocos2d/actions/CCActionInstant.js b/cocos2d/actions/CCActionInstant.js
index b5679ec581..4c324b92ba 100644
--- a/cocos2d/actions/CCActionInstant.js
+++ b/cocos2d/actions/CCActionInstant.js
@@ -29,7 +29,8 @@
*/
/**
- * Instant actions are immediate actions. They don't have a duration like the ActionInterval actions.
+ * !#en Instant actions are immediate actions. They don't have a duration like the ActionInterval actions.
+ * !#zh 即时动作,这种动作立即就会执行,继承自 FiniteTimeAction。
* @class ActionInstant
* @extends FiniteTimeAction
*/
@@ -87,7 +88,8 @@ cc.Show = cc.ActionInstant.extend({
});
/**
- * Show the Node.
+ * !#en Show the Node.
+ * !#zh 立即显示。
* @method show
* @return {ActionInstant}
* @example
@@ -119,7 +121,8 @@ cc.Hide = cc.ActionInstant.extend({
});
/**
- * Hide the node.
+ * !#en Hide the node.
+ * !#zh 立即隐藏。
* @method hide
* @return {ActionInstant}
* @example
@@ -151,7 +154,8 @@ cc.ToggleVisibility = cc.ActionInstant.extend({
});
/**
- * Toggles the visibility of a node.
+ * !#en Toggles the visibility of a node.
+ * !#zh 显隐状态切换。
* @method toggleVisibility
* @return {ActionInstant}
* @example
@@ -166,7 +170,7 @@ cc.toggleVisibility = function () {
* Delete self in the next frame.
* @class RemoveSelf
* @extends ActionInstant
- * @param {Boolean} [isNeedCleanUp=true]
+ * @param {Boolean} isNeedCleanUp
*
* @example
* // example
@@ -200,10 +204,10 @@ cc.RemoveSelf = cc.ActionInstant.extend({
});
/**
- * Create a RemoveSelf object with a flag indicate whether the target should be cleaned up while removing.
- *
+ * !#en Create a RemoveSelf object with a flag indicate whether the target should be cleaned up while removing.
+ * !#zh 从父节点移除自身。
* @method removeSelf
- * @param {Boolean} [isNeedCleanUp=true]
+ * @param {Boolean} isNeedCleanUp
* @return {ActionInstant}
*
* @example
@@ -258,8 +262,8 @@ cc.FlipX = cc.ActionInstant.extend({
});
/**
- * Create a FlipX action to flip or unflip the target.
- *
+ * !#en Create a FlipX action to flip or unflip the target.
+ * !#zh X轴翻转。
* @method flipX
* @param {Boolean} flip Indicate whether the target should be flipped or not
* @return {ActionInstant}
@@ -314,8 +318,8 @@ cc.FlipY = cc.ActionInstant.extend({
});
/**
- * Create a FlipY action to flip or unflip the target.
- *
+ * !#en Create a FlipY action to flip or unflip the target.
+ * !#zh Y轴翻转。
* @method flipY
* @param {Boolean} flip
* @return {ActionInstant}
@@ -378,7 +382,8 @@ cc.Place = cc.ActionInstant.extend({
});
/**
- * Creates a Place action with a position.
+ * !#en Creates a Place action with a position.
+ * !#zh 放置在目标位置。
* @method place
* @param {Vec2|Number} pos
* @param {Number} [y]
@@ -440,7 +445,7 @@ cc.CallFunc = cc.ActionInstant.extend({
if (selectorTarget) {
this._selectorTarget = selectorTarget;
}
- if (data) {
+ if (data !== undefined) {
this._data = data;
}
return true;
@@ -487,7 +492,8 @@ cc.CallFunc = cc.ActionInstant.extend({
});
/**
- * Creates the action with the callback
+ * !#en Creates the action with the callback.
+ * !#zh 执行回调函数。
* @method callFunc
* @param {function} selector
* @param {object|null} [selectorTarget]
diff --git a/cocos2d/actions/CCActionInterval.js b/cocos2d/actions/CCActionInterval.js
index 12a3327062..1fbcf94d2a 100644
--- a/cocos2d/actions/CCActionInterval.js
+++ b/cocos2d/actions/CCActionInterval.js
@@ -29,6 +29,7 @@
*/
/**
+ * !#en
*
An interval action is an action that takes place within a certain period of time.
* It has an start time, and a finish time. The finish time is the parameter
* duration plus the start time.
@@ -40,7 +41,7 @@
*
* For example, you can simulate a Ping Pong effect running the action normally and
* then running it again in Reverse mode.
- *
+ * !#zh 时间间隔动作,这种动作在已定时间内完成,继承 FiniteTimeAction。
* @class ActionInterval
* @extends FiniteTimeAction
* @param {Number} d duration in seconds
@@ -118,7 +119,9 @@ cc.ActionInterval = cc.FiniteTimeAction.extend({
},
/**
- * Implementation of ease motion.
+ * !#en Implementation of ease motion.
+ * !#zh 缓动运动。
+ * @example
* @method easing
* @param {Object} easeObj
* @returns {ActionInterval}
@@ -206,10 +209,13 @@ cc.ActionInterval = cc.FiniteTimeAction.extend({
},
/**
+ * !#en
* Changes the speed of an action, making it take longer (speed>1)
* or less (speed<1) time.
* Useful to simulate 'slow motion' or 'fast forward' effect.
- *
+ * !#zh
+ * 改变一个动作的速度,使它的执行使用更长的时间(speed > 1)
+ * 或更少(speed < 1)可以有效得模拟“慢动作”或“快进”的效果。
* @param speed
* @returns {Action}
*/
@@ -243,8 +249,10 @@ cc.ActionInterval = cc.FiniteTimeAction.extend({
},
/**
+ * !#en
* Repeats an action a number of times.
* To repeat an action forever use the CCRepeatForever action.
+ * !#zh 重复动作可以按一定次数重复一个动作,使用 RepeatForever 动作来永远重复一个动作。
* @method repeat
* @param times
* @returns {ActionInterval}
@@ -261,8 +269,10 @@ cc.ActionInterval = cc.FiniteTimeAction.extend({
},
/**
+ * !#en
* Repeats an action for ever.
* To repeat the an action for a limited number of times use the Repeat action.
+ * !#zh 永远地重复一个动作,有限次数内重复一个动作请使用 Repeat 动作。
* @method repeatForever
* @returns {ActionInterval}
*/
@@ -416,8 +426,10 @@ cc.Sequence = cc.ActionInterval.extend({
});
/**
+ * !#en
* Helper constructor to create an array of sequenceable actions
* The created action will run actions sequentially, one after another.
+ * !#zh 顺序执行动作,创建的动作将按顺序依次运行。
* @method sequence
* @param {Array|FiniteTimeAction} tempArray
* @return {ActionInterval}
@@ -592,7 +604,8 @@ cc.Repeat = cc.ActionInterval.extend({
});
/**
- * Creates a Repeat action. Times is an unsigned integer between 1 and pow(2,30)
+ * !#en Creates a Repeat action. Times is an unsigned integer between 1 and pow(2,30)
+ * !#zh 重复动作,可以按一定次数重复一个动,如果想永远重复一个动作请使用 repeatForever 动作来完成。
* @method repeat
* @param {FiniteTimeAction} action
* @param {Number} times
@@ -694,7 +707,8 @@ cc.RepeatForever = cc.ActionInterval.extend({
});
/**
- * Create a acton which repeat forever
+ * !#en Create a acton which repeat forever
+ * !#zh 永远地重复一个动作,有限次数内重复一个动作请使用 repeat 动作。
* @method repeatForever
* @param {FiniteTimeAction} action
* @return {ActionInterval}
@@ -803,7 +817,8 @@ cc.Spawn = cc.ActionInterval.extend({
});
/**
- * Create a spawn action which runs several actions in parallel.
+ * !#en Create a spawn action which runs several actions in parallel.
+ * !#zh 同步执行动作,同步执行一组动作。
* @method spawn
* @param {Array|FiniteTimeAction}tempArray
* @return {FiniteTimeAction}
@@ -918,8 +933,10 @@ cc.RotateTo = cc.ActionInterval.extend({
});
/**
+ * !#en
* Rotates a Node object to a certain angle by modifying its rotation property.
* The direction will be decided by the shortest angle.
+ * !#zh 旋转到目标角度,通过逐帧修改它的 rotation 属性,旋转方向将由最短的角度决定。
* @method rotateTo
* @param {Number} duration duration in seconds
* @param {Number} deltaAngleX deltaAngleX in degrees.
@@ -1003,8 +1020,10 @@ cc.RotateBy = cc.ActionInterval.extend({
});
/**
+ * !#en
* Rotates a Node object clockwise a number of degrees by modifying its rotation property.
* Relative to its properties to modify.
+ * !#zh 旋转指定的角度。
* @method rotateBy
* @param {Number} duration duration in seconds
* @param {Number} deltaAngleX deltaAngleX in degrees
@@ -1120,10 +1139,12 @@ cc.MoveBy = cc.ActionInterval.extend({
});
/**
+ * !#en
* Moves a Node object x,y pixels by modifying its position property.
* x and y are relative to the position of the object.
* Several MoveBy actions can be concurrently called, and the resulting
* movement will be the sum of individual movements.
+ * !#zh 移动指定的距离。
* @method moveBy
* @param {Number} duration duration in seconds
* @param {Vec2|Number} deltaPos
@@ -1196,9 +1217,11 @@ cc.MoveTo = cc.MoveBy.extend({
});
/**
+ * !#en
* Moves a Node object to the position x,y. x and y are absolute coordinates by modifying its position property.
* Several MoveTo actions can be concurrently called, and the resulting
* movement will be the sum of individual movements.
+ * !#zh 移动到目标位置。
* @method moveTo
* @param {Number} duration duration in seconds
* @param {Vec2} position
@@ -1288,8 +1311,10 @@ cc.SkewTo = cc.ActionInterval.extend({
});
/**
+ * !#en
* Create a action which skews a Node object to given angles by modifying its skewX and skewY properties.
* Changes to the specified value.
+ * !#zh 偏斜到目标角度。
* @method skewTo
* @param {Number} t time in seconds
* @param {Number} sx
@@ -1360,8 +1385,10 @@ cc.SkewBy = cc.SkewTo.extend({
});
/**
+ * !#en
* Skews a Node object by skewX and skewY degrees.
* Relative to its property modification.
+ * !#zh 偏斜指定的角度。
* @method skewBy
* @param {Number} t time in seconds
* @param {Number} sx sx skew in degrees for X axis
@@ -1487,8 +1514,10 @@ cc.JumpBy = cc.ActionInterval.extend({
});
/**
+ * !#en
* Moves a Node object simulating a parabolic jump movement by modifying it's position property.
* Relative to its movement.
+ * !#zh 用跳跃的方式移动指定的距离。
* @method jumpBy
* @param {Number} duration
* @param {Vec2|Number} position
@@ -1568,8 +1597,10 @@ cc.JumpTo = cc.JumpBy.extend({
});
/**
+ * !#en
* Moves a Node object to a parabolic position simulating a jump movement by modifying its position property.
* Jump to the specified location.
+ * !#zh 用跳跃的方式移动到目标位置。
* @method jumpTo
* @param {Number} duration
* @param {Vec2|Number} position
@@ -1712,8 +1743,10 @@ cc.BezierBy = cc.ActionInterval.extend({
});
/**
+ * !#en
* An action that moves the target with a cubic Bezier curve by a certain distance.
* Relative to its movement.
+ * !#zh 按贝赛尔曲线轨迹移动指定的距离。
* @method bezierBy
* @param {Number} t time in seconds
* @param {Array} c Array of points
@@ -1779,7 +1812,8 @@ cc.BezierTo = cc.BezierBy.extend({
}
});
/**
- * An action that moves the target with a cubic Bezier curve to a destination point.
+ * !#en An action that moves the target with a cubic Bezier curve to a destination point.
+ * !#zh 按贝赛尔曲线轨迹移动到目标位置。
* @method bezierTo
* @param {Number} t
* @param {Array} c array of points
@@ -1863,7 +1897,8 @@ cc.ScaleTo = cc.ActionInterval.extend({
}
});
/**
- * Scales a Node object to a zoom factor by modifying it's scale property.
+ * !#en Scales a Node object to a zoom factor by modifying it's scale property.
+ * !#zh 将节点大小缩放到指定的倍数。
* @method scaleTo
* @param {Number} duration
* @param {Number} sx scale parameter in X
@@ -1909,8 +1944,10 @@ cc.ScaleBy = cc.ScaleTo.extend({
}
});
/**
+ * !#en
* Scales a Node object a zoom factor by modifying it's scale property.
* Relative to its changes.
+ * !#zh 按指定的倍数缩放节点大小。
* @method scaleBy
* @param {Number} duration duration in seconds
* @param {Number} sx sx scale parameter in X
@@ -1992,7 +2029,8 @@ cc.Blink = cc.ActionInterval.extend({
}
});
/**
- * Blinks a Node object by modifying it's visible property.
+ * !#en Blinks a Node object by modifying it's visible property.
+ * !#zh 闪烁(基于透明度)。
* @method blink
* @param {Number} duration duration in seconds
* @param {Number} blinks blinks in times
@@ -2057,7 +2095,10 @@ cc.FadeTo = cc.ActionInterval.extend({
});
/**
- * Fades an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from the current value to a custom one.
+ * !#en
+ * Fades an object that implements the cc.RGBAProtocol protocol.
+ * It modifies the opacity from the current value to a custom one.
+ * !#zh 修改透明度到指定值。
* @method fadeTo
* @param {Number} duration
* @param {Number} opacity 0-255, 0 is transparent
@@ -2109,7 +2150,8 @@ cc.FadeIn = cc.FadeTo.extend({
});
/**
- * Fades In an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 0 to 255.
+ * !#en Fades In an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 0 to 255.
+ * !#zh 渐显效果。
* @method fadeIn
* @param {Number} duration duration in seconds
* @return {ActionInterval}
@@ -2155,7 +2197,8 @@ cc.FadeOut = cc.FadeTo.extend({
});
/**
- * Fades Out an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 255 to 0.
+ * !#en Fades Out an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 255 to 0.
+ * !#zh 渐隐效果。
* @method fadeOut
* @param {Number} d duration in seconds
* @return {ActionInterval}
@@ -2235,7 +2278,8 @@ cc.TintTo = cc.ActionInterval.extend({
});
/**
- * Tints a Node that implements the cc.NodeRGB protocol from current tint to a custom one.
+ * !#en Tints a Node that implements the cc.NodeRGB protocol from current tint to a custom one.
+ * !#zh 修改颜色到指定值。
* @method tintTo
* @param {Number} duration
* @param {Number} red 0-255
@@ -2327,8 +2371,10 @@ cc.TintBy = cc.ActionInterval.extend({
});
/**
+ * !#en
* Tints a Node that implements the cc.NodeRGB protocol from current tint to a custom one.
* Relative to their own color change.
+ * !#zh 按照指定的增量修改颜色。
* @method tintBy
* @param {Number} duration duration in seconds
* @param {Number} deltaRed
@@ -2366,7 +2412,8 @@ cc.DelayTime = cc.ActionInterval.extend({
});
/**
- * Delays the action a certain amount of seconds
+ * !#en Delays the action a certain amount of seconds.
+ * !#en 延迟指定的时间量。
* @method delayTime
* @param {Number} d duration in seconds
* @return {ActionInterval}
@@ -2448,7 +2495,8 @@ cc.ReverseTime = cc.ActionInterval.extend({
});
/**
- * Executes an action in reverse order, from time=duration to time=0.
+ * !#en Executes an action in reverse order, from time=duration to time=0.
+ * !#zh 反转目标动作的时间轴。
* @method reverseTime
* @param {FiniteTimeAction} action
* @return {ActionInterval}
@@ -2460,7 +2508,7 @@ cc.reverseTime = function (action) {
return new cc.ReverseTime(action);
};
-/**
+/*
* This API is deprecated, will be replaced by new API from {{#crossLink "Animation"}}cc.Animation{{/crossLink}}
* Animates a sprite given the name of an Animation
* @class Animate
@@ -2616,7 +2664,7 @@ cc.Animate = cc.ActionInterval.extend({
}
});
-/**
+/*
* create the animate with animation
* @method animate
* @param {SpriteFrameAnimation} animation
@@ -2704,7 +2752,8 @@ cc.TargetedAction = cc.ActionInterval.extend({
});
/**
- * Create an action with the specified action and forced target
+ * !#en Create an action with the specified action and forced target.
+ * !#zh 用已有动作和一个新的目标节点创建动作。
* @method targetedAction
* @param {Node} target
* @param {FiniteTimeAction} action
diff --git a/cocos2d/animation/animation-clip.js b/cocos2d/animation/animation-clip.js
index fb54f0a619..680149737f 100644
--- a/cocos2d/animation/animation-clip.js
+++ b/cocos2d/animation/animation-clip.js
@@ -1,6 +1,7 @@
/**
- * Class for animation data handling.
+ * !#en Class for animation data handling.
+ * !#zh 动画剪辑,用于存储动画数据。
* @class AnimationClip
* @extends Asset
* @constructor
@@ -16,7 +17,8 @@ var AnimationClip = cc.Class({
},
/**
- * Duration of this animation
+ * !#en Duration of this animation.
+ * !#zh 动画的持续时间。
* @property duration
* @type {Number}
*/
@@ -25,7 +27,8 @@ var AnimationClip = cc.Class({
},
/**
- * FrameRate of this animation
+ * !#en FrameRate of this animation.
+ * !#zh 动画的帧速率。
* @property sample
* @type {Number}
*/
@@ -34,7 +37,8 @@ var AnimationClip = cc.Class({
},
/**
- * Speed of this animation
+ * !#en Speed of this animation.
+ * !#zh 动画的播放速度。
* @property speed
* @type {Number}
*/
@@ -43,7 +47,8 @@ var AnimationClip = cc.Class({
},
/**
- * WrapMode of this animation
+ * !#en WrapMode of this animation.
+ * !#zh 动画的循环模式。
* @property wrapMode
* @type {WrapMode}
*/
@@ -52,67 +57,11 @@ var AnimationClip = cc.Class({
},
/**
- * Curve data
+ * !#en Curve data.
+ * !#zh 曲线数据。
* @property curveData
* @type {Object}
- * @example
- * {
- * // 根节点不用查找路径
- * // root properties
- * props: {
- * x: [
- * { frame: 0, value: 0, curve: [0,0.5,0.5,1] },
- * { frame: 1, value: 200, curve: null }
- * ]
- * },
- * comps: {
- * // component
- * 'comp-1': {
- * // component properties
- * 'prop-1': [
- * { frame: 0, value: 10, curve: [0,0.5,0.5,1] },
- * { frame: 1, value: 20, curve: null }
- * ]
- * }
- * },
- * paths: {
- * // key 为节点到root的路径名, 通过cc.find找到
- * 'foo/bar': {
- * // node properties
- * props: {
- * x: [
- * { frame: 0, value: 0, curve: [0,0.5,0.5,1] },
- * { frame: 1, value: 200, curve: null }
- * ]
- * },
- * comps: {
- * // component
- * 'comp-1': {
- * // component property
- * 'prop-1': [
- * { frame: 0, value: 10, curve: [0,0.5,0.5,1] },
- * { frame: 1, value: 20, curve: null }
- * ]
- * }
- * }
- * },
- * 'hello': {
- * props: {
- * position: [
- * {
- * frame: 0,
- * value: [0,0],
- * motionPath: [
- * [320, 240, 0, 240, 640, 240],
- * [640, 0, 400, 0, 1000, 0]
- * ]
- * },
- * { frame: 5, value: [640, 480] }
- * ]
- * }
- * }
- * }
- * }
+ * @example {@link utils/api/engine/docs/cocos2d/core/animation-clip/curve-data.js}
*/
curveData: {
default: {},
@@ -120,18 +69,11 @@ var AnimationClip = cc.Class({
},
/**
- * Event data
+ * !#en Event data.
+ * !#zh 事件数据。
* @property events
* @type {Array}
- * @example
- * [
- * frame: 0, func: 'onAnimationEvent1', params:['param-1', 'param-2']
- * frame: 2, func: 'onAnimationEvent3', params:['param-1', 'param-2']
- * frame: 3, func: 'onAnimationEvent2', params:['param-1']
- * // The second event at frame 3
- * frame: 3, func: 'onAnimationEvent4', params:['param-1']
- * frame: 4, func: 'onAnimationEvent4', params:['param-1']
- * ]
+ * @example {@link utils/api/engine/docs/cocos2d/core/animation-clip/event-data.js}
*/
events: {
default: [],
diff --git a/cocos2d/animation/animation-state.js b/cocos2d/animation/animation-state.js
index 53d5658e2e..a1f8d08926 100644
--- a/cocos2d/animation/animation-state.js
+++ b/cocos2d/animation/animation-state.js
@@ -3,9 +3,12 @@ var JS = cc.js;
var AnimationNode = require('./types').AnimationNode;
/**
+ * !#en
* The AnimationState gives full control over animation playback process.
* In most cases the Animation Component is sufficient and easier to use. Use the AnimationState if you need full control.
- *
+ * !#zh
+ * AnimationState 完全控制动画播放过程。
+ * 大多数情况下 动画组件 是足够和易于使用的。如果您需要更多的动画控制接口,请使用 AnimationState。
* @class AnimationState
* @extends AnimationNode
* @constructor
@@ -30,7 +33,8 @@ JS.extend(AnimationState, AnimationNode);
var state = AnimationState.prototype;
/**
- * The clip that is being played by this animation state.
+ * !#en The clip that is being played by this animation state.
+ * !#zh 此动画状态正在播放的剪辑。
* @property clip
* @type {AnimationClip}
* @final
@@ -40,7 +44,8 @@ JS.get(state, 'clip', function () {
});
/**
- * The name of the playing animation.
+ * !#en The name of the playing animation.
+ * !#zh 动画的名字
* @property name
* @type {String}
* @readOnly
diff --git a/cocos2d/animation/playable.js b/cocos2d/animation/playable.js
index 7a3fed11c9..4c959a20bc 100644
--- a/cocos2d/animation/playable.js
+++ b/cocos2d/animation/playable.js
@@ -13,7 +13,8 @@ function Playable () {
var prototype = Playable.prototype;
/**
- * Is playing or paused in play mode?
+ * !#en Is playing or paused in play mode?
+ * !#zh 当前是否正在播放。
* @property isPlaying
* @type {boolean}
* @default false
@@ -24,7 +25,8 @@ JS.get(prototype, 'isPlaying', function () {
}, true);
/**
- * Is currently paused? This can be true even if in edit mode(isPlaying == false).
+ * !#en Is currently paused? This can be true even if in edit mode(isPlaying == false).
+ * !#zh 当前是否正在暂停
* @property isPaused
* @type {boolean}
* @default false
@@ -67,7 +69,8 @@ prototype.onError = virtual;
// public
/**
- * Play this animation
+ * !#en Play this animation.
+ * !#zh 播放动画。
* @method play
*/
prototype.play = function () {
@@ -87,7 +90,8 @@ prototype.play = function () {
};
/**
- * Stop this animation
+ * !#en Stop this animation.
+ * !#zh 停止动画播放。
* @method stop
*/
prototype.stop = function () {
@@ -99,7 +103,8 @@ prototype.stop = function () {
};
/**
- * Pause this animation
+ * !#en Pause this animation.
+ * !#zh 暂停动画。
* @method pause
*/
prototype.pause = function () {
@@ -108,7 +113,8 @@ prototype.pause = function () {
};
/**
- * Resume this animation
+ * !#en Resume this animation.
+ * !#zh 重新播放动画。
* @method resume
*/
prototype.resume = function () {
@@ -117,7 +123,8 @@ prototype.resume = function () {
};
/**
- * Perform a single frame step.
+ * !#en Perform a single frame step.
+ * !#zh 执行一帧动画。
* @method step
*/
prototype.step = function () {
diff --git a/cocos2d/animation/types.js b/cocos2d/animation/types.js
index a1a12b47de..146499e5bf 100644
--- a/cocos2d/animation/types.js
+++ b/cocos2d/animation/types.js
@@ -10,7 +10,8 @@ var WrapModeMask = {
};
/**
- * Specifies how time is treated when it is outside of the keyframe range of an Animation.
+ * !#en Specifies how time is treated when it is outside of the keyframe range of an Animation.
+ * !#zh 动画使用的循环模式。
* @enum WrapMode
* @memberof cc
*/
@@ -73,7 +74,8 @@ cc.WrapMode = WrapMode;
/**
- * The abstract interface for all playing animation.
+ * !#en The abstract interface for all playing animation.
+ * !#zh 所有播放动画的抽象接口。
* @class AnimationNodeBase
* @constructor
* @extends Playable
@@ -92,8 +94,9 @@ JS.extend(AnimationNodeBase, Playable);
AnimationNodeBase.prototype.update = function (deltaTime) {};
-/**
- * The collection and instance of playing animations created by entity.animate.
+/*
+ * !#en The collection and instance of playing animations.
+ * !#zh 动画曲线的集合,根据当前时间计算出每条曲线的状态。
* @class AnimationNode
* @extends AnimationNodeBase
* @constructor
@@ -107,6 +110,8 @@ function AnimationNode (animator, curves, timingInput) {
this.animator = animator;
/**
+ * !#en The curves list.
+ * !#zh 曲线列表。
* @property curves
* @type {AnimCurve[]}
*/
@@ -117,7 +122,7 @@ function AnimationNode (animator, curves, timingInput) {
/**
* !#en The start delay which represents the number of seconds from an animation's start time to the start of
* the active interval.
- * !#zh 延迟多少秒播放
+ * !#zh 延迟多少秒播放。
*
* @property delay
* @type {Number}
@@ -134,7 +139,7 @@ function AnimationNode (animator, curves, timingInput) {
* Values less than zero and NaN values are treated as the value 1.0 for the purpose of timing model
* calculations.
*
- * !#zh 迭代次数, 指动画播放多少次后结束, normalize time. 如 2.5 ( 2次半 )
+ * !#zh 迭代次数,指动画播放多少次后结束, normalize time。 如 2.5(2次半)
*
* @property repeatCount
* @type {Number}
@@ -144,7 +149,7 @@ function AnimationNode (animator, curves, timingInput) {
/**
* !#en The iteration duration of this animation in seconds. (length)
- * !#zh 单次动画的持续时间, 秒
+ * !#zh 单次动画的持续时间,秒。
*
* @property duration
* @type {Number}
@@ -154,7 +159,7 @@ function AnimationNode (animator, curves, timingInput) {
/**
* !#en The animation's playback speed. 1 is normal playback speed.
- * !#zh 播放速率
+ * !#zh 播放速率。
* @property speed
* @type {Number}
* @default: 1.0
@@ -163,7 +168,7 @@ function AnimationNode (animator, curves, timingInput) {
/**
* !#en Wrapping mode of the playing animation.
- * !#zh 动画循环方式
+ * !#zh 动画循环方式。
*
* @property wrapMode
* @type {WrapMode}
@@ -206,7 +211,8 @@ function AnimationNode (animator, curves, timingInput) {
}
/**
- * The current time of this animation in seconds.
+ * !#en The current time of this animation in seconds.
+ * !#zh 动画当前的时间,秒。
* @property time
* @type {Number}
* @default 0
diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js
index fb990d3496..85df6850c2 100644
--- a/cocos2d/audio/CCAudio.js
+++ b/cocos2d/audio/CCAudio.js
@@ -369,11 +369,14 @@ JS.mixin(cc.Audio.prototype, {
if(bgMusic && bgMusic.src !== url && bgMusic.getPlaying()){
bgMusic.stop();
}
- var audio = cc.loader.getRes(url);
+ var item = cc.loader.getItem(url);
+ var audio = item && item.audio ? item.audio : null;
if(!audio){
var self = this;
- cc.loader.load(url, function (error, audio) {
+ cc.loader.load(url, function (error) {
if (!error) {
+ var item = cc.loader.getItem(url);
+ var audio = item && item.audio ? item.audio : null;
audio.play(0, loop);
audio.setVolume(self._musicVolume);
self._currMusic = audio;
@@ -540,11 +543,12 @@ JS.mixin(cc.Audio.prototype, {
}else if(!SWA && i > this._maxAudioInstance){
cc.log("Error: %s greater than %d", url, this._maxAudioInstance);
}else{
- audio = cc.loader.getRes(url);
+ var item = cc.loader.getItem(url);
+ audio = item && item.audio ? item.audio : null;
if(!audio){
cc.loader.load(url);
- var item = cc.loader.getItems().map[url];
- audio = item ? item.content : null;
+ item = cc.loader.getItem(url);
+ audio = item && item.audio ? item.audio : null;
if (!audio) {
return;
}
diff --git a/cocos2d/core/CCNode.js b/cocos2d/core/CCNode.js
index 18b1de4e4c..416e087a12 100644
--- a/cocos2d/core/CCNode.js
+++ b/cocos2d/core/CCNode.js
@@ -33,21 +33,24 @@ var DontDestroy = Flags.DontDestroy;
//var RegisteredInEditor = Flags.RegisteredInEditor;
/**
- * The event type supported by Node
+ * !#en The event type supported by Node
+ * !#zh Node 支持的事件类型
* @enum Node.EventType
* @static
* @namespace Node
*/
var EventType = cc.Enum({
/**
- * The event type for touch start event, you can use its value directly: 'touchstart'
+ * !#en The event type for touch start event, you can use its value directly: 'touchstart'
+ * !#zh 当手指触摸到屏幕时。
* @property TOUCH_START
* @type {String}
* @static
*/
TOUCH_START: 'touchstart',
/**
- * The event type for touch move event, you can use its value directly: 'touchmove'
+ * !#en The event type for touch move event, you can use its value directly: 'touchmove'
+ * !#zh 当手指在屏幕上目标节点区域内移动时。
* @property TOUCH_MOVE
* @type {String}
* @value 1
@@ -55,14 +58,16 @@ var EventType = cc.Enum({
*/
TOUCH_MOVE: 'touchmove',
/**
- * The event type for touch end event, you can use its value directly: 'touchend'
+ * !#en The event type for touch end event, you can use its value directly: 'touchend'
+ * !#zh 当手指在目标节点区域内离开屏幕时。
* @property TOUCH_END
* @type {String}
* @static
*/
TOUCH_END: 'touchend',
/**
- * The event type for touch end event, you can use its value directly: 'touchcancel'
+ * !#en The event type for touch end event, you can use its value directly: 'touchcancel'
+ * !#zh 当手指在目标节点区域外离开屏幕时。
* @property TOUCH_CANCEL
* @type {String}
* @static
@@ -70,42 +75,48 @@ var EventType = cc.Enum({
TOUCH_CANCEL: 'touchcancel',
/**
- * The event type for mouse down events, you can use its value directly: 'mousedown'
+ * !#en The event type for mouse down events, you can use its value directly: 'mousedown'
+ * !#zh 当鼠标按下时触发一次。
* @property MOUSE_DOWN
* @type {String}
* @static
*/
MOUSE_DOWN: 'mousedown',
/**
- * The event type for mouse move events, you can use its value directly: 'mousemove'
+ * !#en The event type for mouse move events, you can use its value directly: 'mousemove'
+ * !#zh 当鼠标在目标节点在目标节点区域中移动时,不论是否按下。
* @property MOUSE_MOVE
* @type {String}
* @static
*/
MOUSE_MOVE: 'mousemove',
/**
- * The event type for mouse enter target events, you can use its value directly: 'mouseenter'
+ * !#en The event type for mouse enter target events, you can use its value directly: 'mouseenter'
+ * !#zh 当鼠标移入目标节点区域时,不论是否按下。
* @property MOUSE_ENTER
* @type {String}
* @static
*/
MOUSE_ENTER: 'mouseenter',
/**
- * The event type for mouse leave target events, you can use its value directly: 'mouseleave'
+ * !#en The event type for mouse leave target events, you can use its value directly: 'mouseleave'
+ * !#zh 当鼠标移出目标节点区域时,不论是否按下。
* @property MOUSE_LEAVE
* @type {String}
* @static
*/
MOUSE_LEAVE: 'mouseleave',
/**
- * The event type for mouse up events, you can use its value directly: 'mouseup'
+ * !#en The event type for mouse up events, you can use its value directly: 'mouseup'
+ * !#zh 当鼠标从按下状态松开时触发一次。
* @property MOUSE_UP
* @type {String}
* @static
*/
MOUSE_UP: 'mouseup',
/**
- * The event type for mouse wheel events, you can use its value directly: 'mousewheel'
+ * !#en The event type for mouse wheel events, you can use its value directly: 'mousewheel'
+ * !#zh 当鼠标滚轮滚动时。
* @property MOUSE_WHEEL
* @type {String}
* @static
@@ -1115,7 +1126,7 @@ var Node = cc.Class({
},
isRunning: function () {
- return this.active;
+ return this._activeInHierarchy;
},
// ACTIONS
diff --git a/cocos2d/core/assets/CCAsset.js b/cocos2d/core/assets/CCAsset.js
index 88e7d2f1e4..bf839fe45c 100644
--- a/cocos2d/core/assets/CCAsset.js
+++ b/cocos2d/core/assets/CCAsset.js
@@ -42,19 +42,17 @@ cc.Asset = cc.Class({
properties: {
/**
* Returns the url of this asset's first raw file, if none of rawFile exists,
- * it will returns the url of this serialized asset.
+ * it will returns an empty string.
*
- * @property url
+ * @property rawUrl
* @type {String}
* @readOnly
*/
- url: {
+ rawUrl: {
get: function () {
if (this._rawFiles) {
if (cc.AssetLibrary) {
- var url = cc.AssetLibrary.getImportedDir(this._uuid);
- var filename = this._rawFiles[0];
- return url + '/' + filename;
+ return cc.AssetLibrary.getImportedDir(this._uuid) + '/' + this._uuid + '/' + this._rawFiles[0];
}
else {
cc.error('asset.url is not usable in core process');
@@ -69,17 +67,17 @@ cc.Asset = cc.Class({
* Returns the url of this asset's raw files, if none of rawFile exists,
* it will returns an empty array.
*
- * @property urls
+ * @property rawUrls
* @type {String[]}
* @readOnly
*/
- urls: {
+ rawUrls: {
get: function () {
if (this._rawFiles) {
if (cc.AssetLibrary) {
- var url = cc.AssetLibrary.getImportedDir(this._uuid);
+ var dir = cc.AssetLibrary.getImportedDir(this._uuid) + '/' + this._uuid + '/';
return this._rawFiles.map(function (filename) {
- return url + '/' + filename;
+ return dir + filename;
});
}
else {
@@ -101,7 +99,7 @@ cc.Asset = cc.Class({
* @default null
* @private
*/
- _rawFiles: null
+ _rawFiles: undefined
},
statics: {
@@ -142,24 +140,14 @@ cc.Asset = cc.Class({
createNode: null,
/**
- * Set raw extname for this asset.
+ * Set raw file names for this asset.
*
* @method _setRawFiles
* @param {String[]} rawFiles
* @private
*/
_setRawFiles: function (rawFiles) {
- rawFiles = rawFiles.map(function (item) {
- if (item.charAt(0) === '.') {
- item = item.slice(1);
- }
- var nextChar = item.charAt(0);
- if (nextChar === '/' || nextChar === '\\') {
- item = item.slice(1);
- }
- return item;
- });
- this._rawFiles = rawFiles.length > 0 ? rawFiles : null;
+ this._rawFiles = rawFiles.length > 0 ? rawFiles : undefined;
}
});
diff --git a/cocos2d/core/assets/CCSpriteAnimation.js b/cocos2d/core/assets/CCSpriteAnimation.js
deleted file mode 100644
index e2fd2f1429..0000000000
--- a/cocos2d/core/assets/CCSpriteAnimation.js
+++ /dev/null
@@ -1,111 +0,0 @@
-/****************************************************************************
- Copyright (c) 2013-2016 Chukong Technologies Inc.
-
- http://www.cocos.com
-
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated engine source code (the "Software"), a limited,
- worldwide, royalty-free, non-assignable, revocable and non-exclusive license
- to use Cocos Creator solely to develop games on your target platforms. You shall
- not use Cocos Creator software for developing other software or tools that's
- used for developing games. You are not granted to publish, distribute,
- sublicense, and/or sell copies of Cocos Creator.
-
- The software or tools in this License Agreement are licensed, not sold.
- Chukong Aipu reserves all rights not expressly granted to you.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- THE SOFTWARE.
- ****************************************************************************/
-
-/**
- * Class for sprite animation asset handling.
- * @class SpriteAnimationAsset
- * @extends Asset
- * @constructor
- */
-var SpriteAnimationAsset = cc.Class({
- name: 'cc.SpriteAnimationAsset',
- extends: cc.Asset,
-
- properties: {
- 0: {
- default: '',
- url: cc.Texture2D
- },
-
- 1: {
- default: '',
- url: cc.Texture2D
- },
-
- 2: {
- default: '',
- url: cc.Texture2D
- },
-
- 3: {
- default: '',
- url: cc.Texture2D
- },
-
- 4: {
- default: '',
- url: cc.Texture2D
- },
-
- 5: {
- default: '',
- url: cc.Texture2D
- },
-
- 6: {
- default: '',
- url: cc.Texture2D
- },
-
- 7: {
- default: '',
- url: cc.Texture2D
- },
-
- 8: {
- default: '',
- url: cc.Texture2D
- },
-
- 9: {
- default: '',
- url: cc.Texture2D
- },
-
- /**
- *
- *
- * @property loop
- * @type {Boolean}
- */
- loop: {
- default: true
- },
-
- /**
- *
- *
- * @property delay
- * @type {Number}
- */
- delay: {
- default: 0.5
- }
- },
-});
-
-cc.SpriteAnimationAsset = SpriteAnimationAsset;
-
-module.exports = SpriteAnimationAsset;
diff --git a/cocos2d/core/assets/index.js b/cocos2d/core/assets/index.js
index 324ccd36d9..b4f9c574a4 100644
--- a/cocos2d/core/assets/index.js
+++ b/cocos2d/core/assets/index.js
@@ -34,6 +34,5 @@ require('./CCSceneAsset');
require('../sprites/CCSpriteFrame');
require('../textures/CCTexture2D');
require('./CCTTFFont');
-require('./CCSpriteAnimation');
require('./CCSpriteAtlas');
//require('./CCTextAsset');
diff --git a/cocos2d/core/base-ui/CCWidgetManager.js b/cocos2d/core/base-ui/CCWidgetManager.js
index d18faa3911..00d3846fa8 100644
--- a/cocos2d/core/base-ui/CCWidgetManager.js
+++ b/cocos2d/core/base-ui/CCWidgetManager.js
@@ -115,6 +115,9 @@ function visitNode (node) {
var widget = node._widget;
if (widget) {
alignToParent(node, widget);
+ if (!CC_EDITOR && widget.isAlignOnce) {
+ widget.enabled = false;
+ }
}
var children = node._children;
for (var i = 0; i < children.length; i++) {
@@ -125,7 +128,7 @@ function visitNode (node) {
}
}
-function visit () {
+function refreshScene () {
var scene = cc.director.getScene();
if (scene) {
widgetManager.isAligning = true;
@@ -221,7 +224,7 @@ var adjustWidgetToAllowResizingInEditor = CC_EDITOR && function (event) {
var widgetManager = cc._widgetManager = {
isAligning: false,
init: function (director) {
- director.on(cc.Director.EVENT_BEFORE_VISIT, visit);
+ director.on(cc.Director.EVENT_BEFORE_VISIT, refreshScene);
},
add: function (widget) {
widget.node._widget = widget;
diff --git a/cocos2d/core/components/CCAnimation.js b/cocos2d/core/components/CCAnimation.js
index f0091467cb..154f57b034 100644
--- a/cocos2d/core/components/CCAnimation.js
+++ b/cocos2d/core/components/CCAnimation.js
@@ -35,6 +35,8 @@ function equalClips (clip1, clip2) {
}
/**
+ * !#en The animation component is used to play back animations.
+ * !#zh Animation 组件用于播放动画。你能指定动画剪辑到动画组件并从脚本控制播放。
* @class Animation
* @extends CCComponent
*/
@@ -66,7 +68,8 @@ var Animation = cc.Class({
},
/**
- * Animation will play the default clip when start game
+ * !#en Animation will play the default clip when start game.
+ * !#zh 在勾选自动播放或调用 play() 时默认播放的动画剪辑。
* @property defaultClip
* @type {AnimationClip}
*/
@@ -101,7 +104,8 @@ var Animation = cc.Class({
},
/**
- * Current played clip
+ * !#en Current played clip.
+ * !#zh 当前播放的动画剪辑。
* @property currentClip
* @type {AnimationClip}
*/
@@ -121,7 +125,8 @@ var Animation = cc.Class({
},
/**
- * All the clips used in this animation
+ * !#en All the clips used in this animation.
+ * !#zh 通过脚本可以访问并播放的 AnimationClip 列表。
* @property _clips
* @type {AnimationClip[]}
* @private
@@ -134,7 +139,8 @@ var Animation = cc.Class({
},
/**
- * Whether the animation should auto play the default clip when start game.
+ * !#en Whether the animation should auto play the default clip when start game.
+ * !#zh 是否在运行游戏后自动播放默认动画剪辑。
* @property playOnLoad
* @type {Boolean}
* @default true
@@ -169,7 +175,8 @@ var Animation = cc.Class({
///////////////////////////////////////////////////////////////////////////////
/**
- * Get all the clips used in this animation
+ * !#en Get all the clips used in this animation.
+ * !#zh 获取动画组件上的所有动画剪辑。
* @method getClips
* @return {AnimationClip[]}
*/
@@ -178,11 +185,15 @@ var Animation = cc.Class({
},
/**
- * Plays an animation and stop other animations.
+ * !#en Plays an animation and stop other animations.
+ * !#zh 播放当前或者指定的动画,并且停止当前正在播放动画。
* @method play
* @param {String} [name] - The name of animation to play. If no name is supplied then the default animation will be played.
* @param {Number} [startTime] - play an animation from startTime
* @return {AnimationState} - The AnimationState of playing animation. In cases where the animation can't be played (ie, there is no default animation or no animation with the specified name), the function will return null.
+ * @example
+ * var animCtrl = this.node.getComponent(cc.Animation);
+ * animCtrl.play("linear");
*/
play: function (name, startTime) {
var state = this.playAdditive(name, startTime);
@@ -200,12 +211,19 @@ var Animation = cc.Class({
},
/**
+ * !#en
* Plays an additive animation, it will not stop other animations.
* If there are other animations playing, then will play several animations at the same time.
+ * !#zh 播放当前或者指定的动画(将不会停止当前播放的动画)。
* @method playAdditive
* @param {String} [name] - The name of animation to play. If no name is supplied then the default animation will be played.
* @param {Number} [startTime] - play an animation from startTime
* @return {AnimationState} - The AnimationState of playing animation. In cases where the animation can't be played (ie, there is no default animation or no animation with the specified name), the function will return null.
+ * @example
+ * // linear_1 and linear_2 at the same time playing.
+ * var animCtrl = this.node.getComponent(cc.Animation);
+ * animCtrl.playAdditive("linear_1");
+ * animCtrl.playAdditive("linear_2");
*/
playAdditive: function (name, startTime) {
this._init();
@@ -232,8 +250,9 @@ var Animation = cc.Class({
},
/**
- * Stops an animation named name. If no name is supplied then stops all playing animations that were started with this Animation.
+ * !#en Stops an animation named name. If no name is supplied then stops all playing animations that were started with this Animation.
* Stopping an animation also Rewinds it to the Start.
+ * !#zh 停止当前或者指定的动画。如果没有指定名字,则停止所有动画。
* @method stop
* @param {String} [name] - The animation to stop, if not supplied then stops all playing animations.
*/
@@ -253,7 +272,8 @@ var Animation = cc.Class({
},
/**
- * Pauses an animation named name. If no name is supplied then pauses all playing animations that were started with this Animation.
+ * !#en Pauses an animation named name. If no name is supplied then pauses all playing animations that were started with this Animation.
+ * !#zh 暂停当前或者指定的动画。如果没有指定名字,则暂停当前正在播放的动画。
* @method pause
* @param {String} [name] - The animation to pauses, if not supplied then pauses all playing animations.
*/
@@ -273,7 +293,8 @@ var Animation = cc.Class({
},
/**
- * Resumes an animation named name. If no name is supplied then resumes all paused animations that were started with this Animation.
+ * !#en Resumes an animation named name. If no name is supplied then resumes all paused animations that were started with this Animation.
+ * !#zh 重新播放指定的动画,如果没有指定名字,则重新播放当前正在播放的动画。
* @method resume
* @param {String} [name] - The animation to resumes, if not supplied then resumes all paused animations.
*/
@@ -293,7 +314,8 @@ var Animation = cc.Class({
},
/**
- * Make an animation named name go to the specified time. If no name is supplied then make all animations go to the specified time.
+ * !#en Make an animation named name go to the specified time. If no name is supplied then make all animations go to the specified time.
+ * !#zh 设置指定动画的播放时间。如果没有指定名字,则设置所有动画的播放时间。
* @method setCurrentTime
* @param {Number} [time] - The time to go to
* @param {String} [name] - Specified animation name, if not supplied then make all animations go to the time.
@@ -315,7 +337,8 @@ var Animation = cc.Class({
},
/**
- * Returns the animation state named name. If no animation with the specified name, the function will return null.
+ * !#en Returns the animation state named name. If no animation with the specified name, the function will return null.
+ * !#zh 获取当前或者指定的动画状态,如果未找到指定动画剪辑则返回 null。
* @method getAnimationState
* @param {String} name
* @return {AnimationState}
@@ -343,7 +366,8 @@ var Animation = cc.Class({
},
/**
- * Adds a clip to the animation with name newName. If a clip with that name already exists it will be replaced with the new clip.
+ * !#en Adds a clip to the animation with name newName. If a clip with that name already exists it will be replaced with the new clip.
+ * !#zh 添加动画剪辑,并且可以重新设置该动画剪辑的名称。
* @method addClip
* @param {AnimationClip} clip - the clip to add
* @param {String} [newName]
@@ -393,7 +417,10 @@ var Animation = cc.Class({
},
/**
- * Remove clip from the animation list. This will remove the clip and any animation states based on it.
+ * !#en Remove clip from the animation list. This will remove the clip and any animation states based on it.
+ * !#zh
+ * 从动画列表中移除指定的动画剪辑,
+ * 如果动画剪辑正在播放并且 force 参数为 true,这会停止该动画剪辑,然后在移除该动画剪辑,反之为 false,则会停止该动画。
* @method removeClip
* @param {AnimationClip} clip
* @param {Boolean} force If force is true, then will always remove the clip and any animation states based on it.
@@ -420,8 +447,10 @@ var Animation = cc.Class({
},
/**
- * Samples animations at the current state.
+ * !#en
+ * Samples animations at the current state.
* This is useful when you explicitly want to set up some animation state, and sample it once.
+ * !#zh 对当前动画进行采样。你可以手动将动画设置到某一个状态,然后采样一次。
* @method sample
*/
sample: function () {
diff --git a/cocos2d/core/components/CCAudioSource.js b/cocos2d/core/components/CCAudioSource.js
index a36efc3952..02a54e893a 100644
--- a/cocos2d/core/components/CCAudioSource.js
+++ b/cocos2d/core/components/CCAudioSource.js
@@ -81,7 +81,7 @@ var AudioSource = cc.Class({
this._clip = value;
},
url: cc.AudioClip,
- tooltip: 'i18n.COMPONENT.audio.clip',
+ tooltip: 'i18n:COMPONENT.audio.clip',
animatable: false
},
@@ -106,7 +106,7 @@ var AudioSource = cc.Class({
}
}
},
- tooltip: 'i18n.COMPONENT.audio.volume'
+ tooltip: 'i18n:COMPONENT.audio.volume'
},
/**
@@ -141,7 +141,7 @@ var AudioSource = cc.Class({
}
},
animatable: false,
- tooltip: 'i18n.COMPONENT.audio.mute',
+ tooltip: 'i18n:COMPONENT.audio.mute',
},
/**
@@ -159,7 +159,7 @@ var AudioSource = cc.Class({
if (this.audio) this.audio.loop = this._loop;
},
animatable: false,
- tooltip: 'i18n.COMPONENT.audio.loop'
+ tooltip: 'i18n:COMPONENT.audio.loop'
},
/**
@@ -170,7 +170,7 @@ var AudioSource = cc.Class({
*/
playOnLoad: {
default: false,
- tooltip: 'i18n.COMPONENT.audio.play_on_load',
+ tooltip: 'i18n:COMPONENT.audio.play_on_load',
animatable: false
}
},
diff --git a/cocos2d/core/components/CCButton.js b/cocos2d/core/components/CCButton.js
index 13748bf4dc..856e2716da 100644
--- a/cocos2d/core/components/CCButton.js
+++ b/cocos2d/core/components/CCButton.js
@@ -416,8 +416,6 @@ var Button = cc.Class({
},
_onMouseMoveOut: function(){
- if (!this.interactable || !this.enabledInHierarchy) return;
-
if (this._hovered) {
this._hovered = false;
this._updateState();
diff --git a/cocos2d/core/components/CCEditBox.js b/cocos2d/core/components/CCEditBox.js
index 7f43a21dea..589066374f 100644
--- a/cocos2d/core/components/CCEditBox.js
+++ b/cocos2d/core/components/CCEditBox.js
@@ -25,12 +25,136 @@
THE SOFTWARE.
****************************************************************************/
+/**
+ * !#en Enum for keyboard return types
+ * !#zh 键盘的返回键类型
+ * @readonly
+ * @enum EditBox.KeyboardReturnType
+ */
+/**
+ * !#en TODO
+ * !#zh 默认
+ * @property {Number} DEFAULT
+ */
+/**
+ * !#en TODO
+ * !#zh 完成类型
+ * @property {Number} DONE
+ */
+/**
+ * !#en TODO
+ * !#zh 发送类型
+ * @property {Number} SEND
+ */
+/**
+ * !#en TODO
+ * !#zh 搜索类型
+ * @property {Number} SEARCH
+ */
+/**
+ * !#en TODO
+ * !#zh 跳转类型
+ * @property {Number} GO
+ */
var KeyboardReturnType = _ccsg.EditBox.KeyboardReturnType;
+
+/**
+ * !#en The EditBox's InputMode defines the type of text that the user is allowed to enter.
+ * !#zh 输入模式
+ * @readonly
+ * @enum EditBox.InputMode
+ */
+/**
+ * !#en TODO
+ * !#zh 用户可以输入任何文本,包括换行符。
+ * @property {Number} ANY
+ */
+/**
+ * !#en The user is allowed to enter an e-mail address.
+ * !#zh 允许用户输入一个电子邮件地址。
+ * @property {Number} EMAIL_ADDR
+ */
+/**
+ * !#en The user is allowed to enter an integer value.
+ * !#zh 允许用户输入一个整数值。
+ * @property {Number} NUMERIC
+ */
+/**
+ * !#en The user is allowed to enter a phone number.
+ * !#zh 允许用户输入一个电话号码。
+ * @property {Number} PHONE_NUMBER
+ */
+/**
+ * !#en The user is allowed to enter a URL.
+ * !#zh 允许用户输入一个 URL。
+ * @property {Number} URL
+ */
+/**
+ * !#en
+ * The user is allowed to enter a real number value.
+ * This extends kEditBoxInputModeNumeric by allowing a decimal point.
+ * !#zh
+ * 允许用户输入一个实数。
+ * @property {Number} DECIMAL
+ */
+/**
+ * !#en The user is allowed to enter any text, except for line breaks.
+ * !#zh 除了换行符以外,用户可以输入任何文本。
+ * @property {Number} SINGLE_LINE
+ */
var InputMode = _ccsg.EditBox.InputMode;
+
+/**
+ * !#en Enum for the EditBox's input flags
+ * !#zh 定义了一些用于设置文本显示和文本格式化的标志位。
+ * @readonly
+ * @enum EditBox.InputFlag
+ */
+/**
+ * !#en
+ * Indicates that the text entered is confidential data that should be
+ * obscured whenever possible. This implies EDIT_BOX_INPUT_FLAG_SENSITIVE.
+ * !#zh
+ * 表明输入的文本是保密的数据,任何时候都应该隐藏起来,它隐含了 EDIT_BOX_INPUT_FLAG_SENSITIVE。
+ * @property {Number} PASSWORD
+ */
+/**
+ * !#en
+ * Indicates that the text entered is sensitive data that the
+ * implementation must never store into a dictionary or table for use
+ * in predictive, auto-completing, or other accelerated input schemes.
+ * A credit card number is an example of sensitive data.
+ * !#zh
+ * 表明输入的文本是敏感数据,它禁止存储到字典或表里面,也不能用来自动补全和提示用户输入。
+ * 一个信用卡号码就是一个敏感数据的例子。
+ * @property {Number} SENSITIVE
+ */
+/**
+ * !#en
+ * This flag is a hint to the implementation that during text editing,
+ * the initial letter of each word should be capitalized.
+ * !#zh
+ * 这个标志用来指定在文本编辑的时候,是否把每一个单词的首字母大写。
+ * @property {Number} INITIAL_CAPS_WORD
+ */
+/**
+ * !#en
+ * This flag is a hint to the implementation that during text editing,
+ * the initial letter of each sentence should be capitalized.
+ * !#zh
+ * 这个标志用来指定在文本编辑是否每个句子的首字母大写。
+ * @property {Number} INITIAL_CAPS_SENTENCE
+ */
+/**
+ * !#en Capitalize all characters automatically.
+ * !#zh 自动把输入的所有字符大写。
+ * @property {Number} INITIAL_CAPS_ALL_CHARACTERS
+ */
var InputFlag = _ccsg.EditBox.InputFlag;
/**
- * cc.EditBox is a component for inputing text, you can use it to gather small amounts of text from users.
+ * !#en cc.EditBox is a component for inputing text, you can use it to gather small amounts of text from users.
+ * !#zh EditBox 组件,用于获取用户的输入文本。
* @class EditBox
* @extends _RendererUnderSG
*/
@@ -49,7 +173,8 @@ var EditBox = cc.Class({
_useOriginalSize: true,
_string: '',
/**
- * Input string of EditBox.
+ * !#en Input string of EditBox.
+ * !#zh 输入框的初始输入内容,如果为空则会显示占位符的文本。
* @property {String} string
*/
string: {
@@ -63,8 +188,9 @@ var EditBox = cc.Class({
},
/**
- * The background image of EditBox.
- * @property {cc.SpriteFrame} backGroundImage
+ * !#en The background image of EditBox.
+ * !#zh 输入框的背景图片
+ * @property {SpriteFrame} backGroundImage
*/
backgroundImage: {
tooltip: 'i18n:COMPONENT.editbox.backgroundImage',
@@ -84,8 +210,12 @@ var EditBox = cc.Class({
},
/**
+ * !#en
* The return key type of EditBox.
* Note: it is meaningless for web platforms and desktop platforms.
+ * !#zh
+ * 指定移动设备上面回车按钮的样式。
+ * 注意:这个选项对 web 平台与 desktop 平台无效。
* @property {EditBox.KeyboardReturnType} returnType
* @default KeyboardReturnType.DEFAULT
*/
@@ -100,7 +230,8 @@ var EditBox = cc.Class({
},
/**
- * Set the input flags that are to be applied to the EditBox.
+ * !#en Set the input flags that are to be applied to the EditBox.
+ * !#zh 指定输入标志位,可以指定输入方式为密码或者单词首字母大写。
* @property {EditBox.InputFlag} inputFlag
* @default InputFlag.INITIAL_CAPS_ALL_CHARACTERS
*/
@@ -113,8 +244,11 @@ var EditBox = cc.Class({
}
},
/**
+ * !#en
* Set the input mode of the edit box.
* If you pass ANY, it will create a multiline EditBox.
+ * !#zh
+ * 指定输入模式: ANY表示多行输入,其它都是单行输入,移动平台上还可以指定键盘样式。
* @property {EditBox.InputMode} inputMode
* @default InputMode.ANY
*/
@@ -128,7 +262,8 @@ var EditBox = cc.Class({
},
/**
- * Font size of the input text.
+ * !#en Font size of the input text.
+ * !#zh 输入框文本的字体大小
* @property {Number} fontSize
*/
fontSize: {
@@ -140,7 +275,8 @@ var EditBox = cc.Class({
},
/**
- * Change the lineHeight of displayed text.
+ * !#en Change the lineHeight of displayed text.
+ * !#zh 输入框文本的行高。
* @property {Number} lineHeight
*/
lineHeight: {
@@ -152,8 +288,9 @@ var EditBox = cc.Class({
},
/**
- * Font color of the input text.
- * @property {cc.Color} fontColor
+ * !#en Font color of the input text.
+ * !#zh 输入框文本的颜色。
+ * @property {Color} fontColor
*/
fontColor: {
tooltip: 'i18n:COMPONENT.editbox.font_color',
@@ -164,7 +301,8 @@ var EditBox = cc.Class({
},
/**
- * The display text of placeholder.
+ * !#en The display text of placeholder.
+ * !#zh 输入框占位符的文本内容。
* @property {String} placeholder
*/
placeholder: {
@@ -176,7 +314,8 @@ var EditBox = cc.Class({
},
/**
- * The font size of placeholder.
+ * !#en The font size of placeholder.
+ * !#zh 输入框占位符的字体大小。
* @property {Number} placeholderFontSize
*/
placeholderFontSize: {
@@ -188,8 +327,9 @@ var EditBox = cc.Class({
},
/**
- * The font color of placeholder.
- * @property {cc.Color} placeholderFontColor
+ * !#en The font color of placeholder.
+ * !#zh 输入框最大允许输入的字符个数。
+ * @property {Color} placeholderFontColor
*/
placeholderFontColor: {
tooltip: 'i18n:COMPONENT.editbox.placeholder_font_color',
@@ -200,7 +340,8 @@ var EditBox = cc.Class({
},
/**
- * The maximize input length of EditBox.
+ * !#en The maximize input length of EditBox.
+ * !#zh 输入框最大允许输入的字符个数。
* @property {Number} maxLength
*/
maxLength: {
@@ -212,8 +353,9 @@ var EditBox = cc.Class({
},
/**
- * The event handler to be called when EditBox began to edit text.
- * @property {cc.Component.EventHandler} editingDidBegin
+ * !#en The event handler to be called when EditBox began to edit text.
+ * !#zh 开始编辑文本输入框触发的事件回调。
+ * @property {Component.EventHandler} editingDidBegin
*/
editingDidBegan: {
default: [],
@@ -221,8 +363,9 @@ var EditBox = cc.Class({
},
/**
- * The event handler to be called when EditBox text changes.
- * @property {cc.Component.EventHandler} textChanged
+ * !#en The event handler to be called when EditBox text changes.
+ * !#zh 编辑文本输入框时触发的事件回调。
+ * @property {Component.EventHandler} textChanged
*/
textChanged: {
default: [],
@@ -230,8 +373,9 @@ var EditBox = cc.Class({
},
/**
- * The event handler to be called when EditBox edit ends.
- * @property {cc.Component.EventHandler} editingDidEnded
+ * !#en The event handler to be called when EditBox edit ends.
+ * !#zh 结束编辑文本输入框时触发的事件回调。
+ * @property {Component.EventHandler} editingDidEnded
*/
editingDidEnded: {
default: [],
diff --git a/cocos2d/core/components/CCRendererInSG.js b/cocos2d/core/components/CCRendererInSG.js
index d896cdef78..9e37e363c4 100644
--- a/cocos2d/core/components/CCRendererInSG.js
+++ b/cocos2d/core/components/CCRendererInSG.js
@@ -105,7 +105,7 @@ var RendererInSG = cc.Class({
parentNode.removeChild(replaced);
parentNode.addChild(sgNode);
sgNode.arrivalOrder = replaced.arrivalOrder;
- if (cc.renderer) {
+ if ( !CC_JSB ) {
cc.renderer.childrenOrderDirty = parentNode._reorderChildDirty = true;
}
diff --git a/cocos2d/core/components/CCWidget.js b/cocos2d/core/components/CCWidget.js
index 1724ac3126..4d61b70143 100644
--- a/cocos2d/core/components/CCWidget.js
+++ b/cocos2d/core/components/CCWidget.js
@@ -378,6 +378,22 @@ var Widget = cc.Class({
animatable: false
},
+ /**
+ * !#en TODO
+ * !#zh
+ * 开启后仅会在 onEnable 的当帧结束时对齐一次,然后立刻禁用当前组件。
+ * 这样便于脚本或动画继续控制当前节点。
+ * 注意:onEnable 时所在的那一帧仍然会进行对齐。
+ * @property isAlignOnce
+ * @type {Boolean}
+ * @default false
+ */
+ isAlignOnce: {
+ default: false,
+ tooltip: 'i18n:COMPONENT.widget.align_once',
+ displayName: "AlignOnce"
+ },
+
//
/**
@@ -404,11 +420,11 @@ var Widget = cc.Class({
_originalHeight: 0
},
- onLoad: function () {
+ onEnable: function () {
cc._widgetManager.add(this);
},
- onDestroy: function () {
+ onDisable: function () {
cc._widgetManager.remove(this);
},
diff --git a/cocos2d/core/editbox/CCdomNode.js b/cocos2d/core/editbox/CCdomNode.js
index d772073465..d811717f15 100644
--- a/cocos2d/core/editbox/CCdomNode.js
+++ b/cocos2d/core/editbox/CCdomNode.js
@@ -239,7 +239,7 @@ cc.DOM.methods = /** @lends cc.DOM# */{
this.canvas.height = locContentSize.height;
}
this.setNodeDirty();
- this.redraw();
+ // this.redraw();
},
/**
@@ -261,7 +261,7 @@ cc.DOM.methods = /** @lends cc.DOM# */{
this.canvas.width = locContentSize.width;
}
this.setNodeDirty();
- this.redraw();
+ // this.redraw();
},
/**
@@ -283,7 +283,7 @@ cc.DOM.methods = /** @lends cc.DOM# */{
this.canvas.height = locContentSize.height;
}
this.setNodeDirty();
- this.redraw();
+ // this.redraw();
},
/**
diff --git a/cocos2d/core/event-manager/CCEventListener.js b/cocos2d/core/event-manager/CCEventListener.js
index 18a4f2ecb4..de0a27baa8 100644
--- a/cocos2d/core/event-manager/CCEventListener.js
+++ b/cocos2d/core/event-manager/CCEventListener.js
@@ -23,27 +23,36 @@
THE SOFTWARE.
****************************************************************************/
/**
+ * !#en
*
* The base class of event listener.
* If you need custom listener which with different callback, you need to inherit this class.
* For instance, you could refer to EventListenerAcceleration, EventListenerKeyboard,
* EventListenerTouchOneByOne, EventListenerCustom.
*
+ *
+ * !#zh
+ * 封装用户的事件处理逻辑。
+ * 注意:这是一个抽象类,开发者不应该直接实例化这个类,请参考 cc.EventListener.create。
+ *
* @class EventListener
+ * @param {Number} type
+ * @param {Number} listenerID
+ * @param {Number} callback
*/
cc.EventListener = cc._Class.extend(/** @lends cc.EventListener# */{
- _onEvent: null, // Event callback function
- _type: 0, // Event listener type
- _listenerID: null, // Event listener ID
- _registered: false, // Whether the listener has been added to dispatcher.
+ _onEvent: null, // Event callback function
+ _type: 0, // Event listener type
+ _listenerID: null, // Event listener ID
+ _registered: false, // Whether the listener has been added to dispatcher.
- _fixedPriority: 0, // The higher the number, the higher the priority, 0 is for scene graph base priority.
- _node: null, // scene graph based priority
+ _fixedPriority: 0, // The higher the number, the higher the priority, 0 is for scene graph base priority.
+ _node: null, // scene graph based priority
_target: null,
- _paused: true, // Whether the listener is paused
- _isEnabled: true, // Whether the listener is enabled
+ _paused: true, // Whether the listener is paused
+ _isEnabled: true, // Whether the listener is enabled
- /**
+ /*
* Initializes event with type and callback function.
* @param {Number} type
* @param {String} listenerID
@@ -55,7 +64,7 @@ cc.EventListener = cc._Class.extend(/** @lends cc.EventListener# */{
this._listenerID = listenerID || "";
},
- /**
+ /*
*
* Sets paused state for the listener
* The paused state is only used for scene graph priority listeners.
@@ -72,7 +81,7 @@ cc.EventListener = cc._Class.extend(/** @lends cc.EventListener# */{
this._paused = paused;
},
- /**
+ /*
* Checks whether the listener is paused.
* @returns {Boolean}
* @private
@@ -81,7 +90,7 @@ cc.EventListener = cc._Class.extend(/** @lends cc.EventListener# */{
return this._paused;
},
- /**
+ /*
* Marks the listener was registered by EventDispatcher.
* @param {Boolean} registered
* @private
@@ -90,7 +99,7 @@ cc.EventListener = cc._Class.extend(/** @lends cc.EventListener# */{
this._registered = registered;
},
- /**
+ /*
* Checks whether the listener was registered by EventDispatcher
* @returns {Boolean}
* @private
@@ -99,7 +108,7 @@ cc.EventListener = cc._Class.extend(/** @lends cc.EventListener# */{
return this._registered;
},
- /**
+ /*
* Gets the type of this listener
* @note It's different from `EventType`, e.g. TouchEvent has two kinds of event listeners - EventListenerOneByOne, EventListenerAllAtOnce
* @returns {Number}
@@ -109,7 +118,7 @@ cc.EventListener = cc._Class.extend(/** @lends cc.EventListener# */{
return this._type;
},
- /**
+ /*
* Gets the listener ID of this listener
* When event is being dispatched, listener ID is used as key for searching listeners according to event type.
* @returns {String}
@@ -119,7 +128,7 @@ cc.EventListener = cc._Class.extend(/** @lends cc.EventListener# */{
return this._listenerID;
},
- /**
+ /*
* Sets the fixed priority for this listener
* @note This method is only used for `fixed priority listeners`, it needs to access a non-zero value. 0 is reserved for scene graph priority listeners
* @param {Number} fixedPriority
@@ -129,7 +138,7 @@ cc.EventListener = cc._Class.extend(/** @lends cc.EventListener# */{
this._fixedPriority = fixedPriority;
},
- /**
+ /*
* Gets the fixed priority of this listener
* @returns {Number} 0 if it's a scene graph priority listener, non-zero for fixed priority listener
* @private
@@ -138,7 +147,7 @@ cc.EventListener = cc._Class.extend(/** @lends cc.EventListener# */{
return this._fixedPriority;
},
- /**
+ /*
* Sets scene graph priority for this listener
* @param {_ccsg.Node|Node} node
* @private
@@ -148,7 +157,7 @@ cc.EventListener = cc._Class.extend(/** @lends cc.EventListener# */{
this._node = node;
},
- /**
+ /*
* Gets scene graph priority of this listener
* @returns {_ccsg.Node|cc.Node} if it's a fixed priority listener, non-null for scene graph priority listener
* @private
@@ -158,7 +167,9 @@ cc.EventListener = cc._Class.extend(/** @lends cc.EventListener# */{
},
/**
- * Checks whether the listener is available.
+ * !#en Checks whether the listener is available.
+ * !#zh 检测监听器是否有效
+ * @method checkAvailable
* @returns {Boolean}
*/
checkAvailable: function () {
@@ -166,7 +177,9 @@ cc.EventListener = cc._Class.extend(/** @lends cc.EventListener# */{
},
/**
- * Clones the listener, its subclasses have to override this method.
+ * !#en Clones the listener, its subclasses have to override this method.
+ * !#zh 克隆监听器,它的子类必须重写此方法。
+ * @method clone
* @returns {EventListener}
*/
clone: function () {
@@ -174,26 +187,30 @@ cc.EventListener = cc._Class.extend(/** @lends cc.EventListener# */{
},
/**
- * Enables or disables the listener
+ * !#en Enables or disables the listener
+ * !#zh 启用或禁用监听器。
+ * @method setEnabled
+ * @param {Boolean} enabled
* @note Only listeners with `enabled` state will be able to receive events.
* When an listener was initialized, it's enabled by default.
* An event listener can receive events when it is enabled and is not paused.
* paused state is always false when it is a fixed priority listener.
- * @param {Boolean} enabled
*/
setEnabled: function(enabled){
this._isEnabled = enabled;
},
/**
- * Checks whether the listener is enabled
+ * !#en Checks whether the listener is enabled
+ * !#zh 检查监听器是否可用。
+ * @method isEnabled
* @returns {Boolean}
*/
isEnabled: function(){
return this._isEnabled;
},
- /**
+ /*
*
Currently JavaScript Bindings (JSB), in some cases, needs to use retain and release. This is a bug in JSB,
* and the ugly workaround is to use retain/release. So, these 2 methods were added to be compatible with JSB.
* This is a hack, and should be removed once JSB fixes the retain/release bug
@@ -209,7 +226,7 @@ cc.EventListener = cc._Class.extend(/** @lends cc.EventListener# */{
*/
retain:function () {
},
- /**
+ /*
*
Currently JavaScript Bindings (JSB), in some cases, needs to use retain and release. This is a bug in JSB,
* and the ugly workaround is to use retain/release. So, these 2 methods were added to be compatible with JSB.
* This is a hack, and should be removed once JSB fixes the retain/release bug
@@ -229,49 +246,58 @@ cc.EventListener = cc._Class.extend(/** @lends cc.EventListener# */{
// event listener type
/**
- * The type code of unknown event listener.
+ * !#en The type code of unknown event listener.
+ * !#zh 未知的事件监听器类型。
+ * @property EventListener.UNKNOWN
* @constant
* @type {Number}
*/
cc.EventListener.UNKNOWN = 0;
-/**
- * The type code of one by one touch event listener.
+/*
+ * !#en The type code of one by one touch event listener.
+ * !#zh 触摸事件监听器类型,触点会一个一个得分开被派发。
* @constant
* @type {Number}
*/
cc.EventListener.TOUCH_ONE_BY_ONE = 1;
-/**
- * The type code of all at once touch event listener.
+/*
+ * !#en The type code of all at once touch event listener.
+ * !#zh 触摸事件监听器类型,触点会被一次性全部派发。
* @constant
* @type {Number}
*/
cc.EventListener.TOUCH_ALL_AT_ONCE = 2;
/**
- * The type code of keyboard event listener.
- * @constant
+ * !#en The type code of keyboard event listener.
+ * !#zh 键盘事件监听器类型。
+ * @constant EventListener.KEYBOARD
* @type {Number}
*/
cc.EventListener.KEYBOARD = 3;
-/**
- * The type code of mouse event listener.
+/*
+ * !#en The type code of mouse event listener.
+ * !#zh 鼠标事件监听器类型。
* @constant
* @type {Number}
*/
cc.EventListener.MOUSE = 4;
/**
- * The type code of focus event listener.
- * @constant
+ * !#en The type code of focus event listener.
+ * !#zh 加速器事件监听器类型。
+ * @constant EventListener.ACCELERATION
* @type {Number}
*/
cc.EventListener.ACCELERATION = 6;
-/**
- * The type code of Focus change event listener.
+/*
+ * !#en The type code of Focus change event listener.
+ * !#zh 焦点事件监听器类型。
* @constant
* @type {Number}
*/
cc.EventListener.FOCUS = 7;
-/**
- * The type code of custom event listener.
+/*
+ * !#en The type code of custom event listener.
+ * !#zh 自定义事件监听器类型。
* @constant
* @type {Number}
*/
@@ -423,12 +449,16 @@ cc._EventListenerTouchAllAtOnce = cc.EventListener.extend({
cc._EventListenerTouchAllAtOnce.LISTENER_ID = "__cc_touch_all_at_once";
/**
- * Create a EventListener object by json object
+ * !#en
+ * Create a EventListener object with configuration including the event type, handlers and other parameters.
+ * In handlers, this refer to the event listener object itself.
+ * You can also pass custom parameters in the configuration object,
+ * 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}
- * todo: It should be the direct use new
* @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/CCEventManager.js b/cocos2d/core/event-manager/CCEventManager.js
index 0a214f5c6d..ea7146ae68 100644
--- a/cocos2d/core/event-manager/CCEventManager.js
+++ b/cocos2d/core/event-manager/CCEventManager.js
@@ -89,13 +89,20 @@ var __getListenerID = function (event) {
};
/**
+ * !#en
*
* cc.eventManager is a singleton object which manages event listener subscriptions and event dispatching.
*
* The EventListener list is managed in such way so that event listeners can be added and removed
* while events are being dispatched.
*
+ * !#zh
+ * 事件管理器,它主要管理事件监听器注册和派发系统事件。
+ * 原始设计中,它支持鼠标,触摸,键盘,陀螺仪和自定义事件。
+ * 在 Creator 的设计中,鼠标,触摸和自定义事件的监听和派发请参考 http://cocos.com/docs/creator/scripting/events.html。
+ *
* @class eventManager
+ * @example {@link utils/api/engine/docs/cocos2d/core/event-manager/CCEventManager/addListener.js}
*/
cc.eventManager = {
//Priority dirty flag
@@ -130,10 +137,11 @@ cc.eventManager = {
},
/**
- * Pauses all listeners which are associated the specified target.
+ * !#en Pauses all listeners which are associated the specified target.
+ * !#zh 暂停传入的 node 相关的所有监听器的事件响应。
* @method pauseTarget
* @param {Node} node
- * @param {Boolean} [recursive=false]
+ * @param {Boolean} recursive
*/
pauseTarget: function (node, recursive) {
var listeners = this._nodeListenersMap[node.__instanceId], i, len;
@@ -149,10 +157,11 @@ cc.eventManager = {
},
/**
- * Resumes all listeners which are associated the specified target.
+ * !#en Resumes all listeners which are associated the specified target.
+ * !#zh 恢复传入的 node 相关的所有监听器的事件响应。
* @method resumeTarget
* @param {Node} node
- * @param {Boolean} [recursive=false]
+ * @param {Boolean} recursive
*/
resumeTarget: function (node, recursive) {
var listeners = this._nodeListenersMap[node.__instanceId], i, len;
@@ -638,11 +647,19 @@ cc.eventManager = {
},
/**
+ * !#en
*
- * Adds a event listener for a specified event.
- * if the parameter "nodeOrPriority" is a node, it means to add a event listener for a specified event with the priority of scene graph.
- * if the parameter "nodeOrPriority" is a Number, it means to add a event listener for a specified event with the fixed priority.
+ * Adds a event listener for a specified event.
+ * if the parameter "nodeOrPriority" is a node,
+ * it means to add a event listener for a specified event with the priority of scene graph.
+ * if the parameter "nodeOrPriority" is a Number,
+ * it means to add a event listener for a specified event with the fixed priority.
*
+ * !#zh
+ * 将事件监听器添加到事件管理器中。
+ * 如果参数 “nodeOrPriority” 是节点,优先级由 node 的渲染顺序决定,显示在上层的节点将优先收到事件。
+ * 如果参数 “nodeOrPriority” 是数字,优先级则固定为该参数的数值,数字越小,优先级越高。
+ *
* @method addListener
* @param {EventListener|Object} listener - The listener of a specified event or a object of some event parameters.
* @param {Node|Number} nodeOrPriority - The priority of the listener is based on the draw order of this node or fixedPriority The fixed priority of the listener.
@@ -688,8 +705,9 @@ cc.eventManager = {
return listener;
},
- /**
- * Adds a Custom event listener. It will use a fixed priority of 1.
+ /*
+ * !#en Adds a Custom event listener. It will use a fixed priority of 1.
+ * !#zh 向事件管理器添加一个自定义事件监听器。
* @method addCustomListener
* @param {String} eventName
* @param {Function} callback
@@ -702,9 +720,11 @@ cc.eventManager = {
},
/**
- * Remove a listener.
+ * !#en Remove a listener.
+ * !#zh 移除一个已添加的监听器。
* @method removeListener
* @param {EventListener} listener - an event listener or a registered node target
+ * @example {@link utils/api/engine/docs/cocos2d/core/event-manager/CCEventManager/removeListener.js}
*/
removeListener: function (listener) {
if (listener == null)
@@ -790,10 +810,22 @@ cc.eventManager = {
},
/**
- * Removes all listeners with the same event listener type or removes all listeners of a node
+ * !#en Removes all listeners with the same event listener type or removes all listeners of a node.
+ * !#zh
+ * 移除注册到 eventManager 中指定类型的所有事件监听器。
+ * 1. 如果传入的第一个参数类型是 Node,那么事件管理器将移除与该对象相关的所有事件监听器。
+ * (如果第二参数 recursive 是 true 的话,就会连同该对象的子控件上所有的事件监听器也一并移除)
+ * 2. 如果传入的第一个参数类型是 Number(该类型 EventListener 中定义的事件类型),
+ * 那么事件管理器将移除该类型的所有事件监听器。
+ *
+ * 下列是目前存在监听器类型:
+ * cc.EventListener.UNKNOWN
+ * cc.EventListener.KEYBOARD
+ * cc.EventListener.ACCELERATION,
+ *
* @method removeListeners
* @param {Number|Node} listenerType - listenerType or a node
- * @param {Boolean} [recursive=false]
+ * @param {Boolean} recursive
*/
removeListeners: function (listenerType, recursive) {
var i, _t = this;
@@ -847,8 +879,9 @@ cc.eventManager = {
}
},
- /**
- * Removes all custom listeners with the same event name
+ /*
+ * !#en Removes all custom listeners with the same event name.
+ * !#zh 移除同一事件名的自定义事件监听器。
* @method removeCustomListeners
* @param {String} customEventName
*/
@@ -857,7 +890,8 @@ cc.eventManager = {
},
/**
- * Removes all listeners
+ * !#en Removes all listeners
+ * !#zh 移除所有事件监听器。
* @method removeAllListeners
*/
removeAllListeners: function () {
@@ -869,7 +903,8 @@ cc.eventManager = {
},
/**
- * Sets listener's priority with fixed value.
+ * !#en Sets listener's priority with fixed value.
+ * !#zh 设置 FixedPriority 类型监听器的优先级。
* @method setPriority
* @param {EventListener} listener
* @param {Number} fixedPriority
@@ -898,7 +933,8 @@ cc.eventManager = {
},
/**
- * Whether to enable dispatching events
+ * !#en Whether to enable dispatching events
+ * !#zh 启用或禁用事件管理器,禁用后不会分发任何事件。
* @method setEnabled
* @param {Boolean} enabled
*/
@@ -907,7 +943,8 @@ cc.eventManager = {
},
/**
- * Checks whether dispatching events is enabled
+ * !#en Checks whether dispatching events is enabled
+ * !#zh 检测事件管理器是否启用。
* @method isEnabled
* @returns {Boolean}
*/
@@ -915,8 +952,9 @@ cc.eventManager = {
return this._isEnabled;
},
- /**
- * Dispatches the event, also removes all EventListeners marked for deletion from the event dispatcher list.
+ /*
+ * !#en Dispatches the event, also removes all EventListeners marked for deletion from the event dispatcher list.
+ * !#zh 分发事件。
* @method dispatchEvent
* @param {Event} event
*/
@@ -950,8 +988,9 @@ cc.eventManager = {
return event.isStopped();
},
- /**
- * Dispatches a Custom Event with a event name an optional user data
+ /*
+ * !#en Dispatches a Custom Event with a event name an optional user data
+ * !#zh 分发自定义事件。
* @method dispatchCustomEvent
* @param {String} eventName
* @param {*} optionalUserData
diff --git a/cocos2d/core/event-manager/CCSystemEvent.js b/cocos2d/core/event-manager/CCSystemEvent.js
index 49862b119f..f2dd6198f3 100644
--- a/cocos2d/core/event-manager/CCSystemEvent.js
+++ b/cocos2d/core/event-manager/CCSystemEvent.js
@@ -28,32 +28,30 @@ var JS = cc.js;
var Event = cc.Event;
/**
- * The type code of Touch event.
+ * !#en The type code of Touch event.
+ * !#zh 触摸事件类型
* @constant
* @type {String}
*/
cc.Event.TOUCH = 'touch';
/**
- * The type code of Mouse event.
+ * !#en The type code of Mouse event.
+ * !#zh 鼠标事件类型
* @constant
* @type {String}
*/
cc.Event.MOUSE = 'mouse';
/**
- * The type code of UI focus event.
- * @constant
- * @type {String}
- */
-cc.Event.FOCUS = 'focus';
-/**
- * The type code of Keyboard event.
+ * !#en The type code of Keyboard event.
+ * !#zh 键盘事件类型
* @constant
* @memberof cc.Event
* @type {String}
*/
cc.Event.KEYBOARD = 'keyboard';
/**
- * The type code of Acceleration event.
+ * !#en The type code of Acceleration event.
+ * !#zh 加速器事件类型
* @constant
* @memberof cc.Event
* @type {String}
@@ -61,7 +59,8 @@ cc.Event.KEYBOARD = 'keyboard';
cc.Event.ACCELERATION = 'acceleration';
/**
- * The mouse event
+ * !#en The mouse event
+ * !#zh 鼠标事件类型
* @class Event.EventMouse
* @constructor
* @extends Event
@@ -83,7 +82,8 @@ var EventMouse = function (eventType, bubbles) {
JS.extend(EventMouse, cc.Event);
JS.mixin(EventMouse.prototype, {
/**
- * Sets scroll data.
+ * !#en Sets scroll data.
+ * !#zh 设置鼠标的滚动数据。
* @method setScrollData
* @param {Number} scrollX
* @param {Number} scrollY
@@ -94,7 +94,8 @@ JS.mixin(EventMouse.prototype, {
},
/**
- * Returns the x axis scroll value.
+ * !#en Returns the x axis scroll value.
+ * !#zh 获取鼠标滚动的X轴距离,只有滚动时才有效。
* @method getScrollX
* @returns {Number}
*/
@@ -103,7 +104,8 @@ JS.mixin(EventMouse.prototype, {
},
/**
- * Returns the y axis scroll value.
+ * !#en Returns the y axis scroll value.
+ * !#zh 获取滚轮滚动的 Y 轴距离,只有滚动时才有效。
* @method getScrollY
* @returns {Number}
*/
@@ -112,7 +114,8 @@ JS.mixin(EventMouse.prototype, {
},
/**
- * Sets cursor location.
+ * !#en Sets cursor location.
+ * !#zh 设置当前鼠标位置。
* @method setLocation
* @param {Number} x
* @param {Number} y
@@ -123,7 +126,8 @@ JS.mixin(EventMouse.prototype, {
},
/**
- * Returns cursor location.
+ * !#en Returns cursor location.
+ * !#zh 获取鼠标位置对象,对象包含 x 和 y 属性。
* @method getLocation
* @return {Vec2} location
*/
@@ -132,7 +136,8 @@ JS.mixin(EventMouse.prototype, {
},
/**
- * Returns the current cursor location in screen coordinates.
+ * !#en Returns the current cursor location in screen coordinates.
+ * !#zh 获取当前事件在游戏窗口内的坐标位置对象,对象包含 x 和 y 属性。
* @method getLocationInView
* @return {Vec2}
*/
@@ -146,7 +151,8 @@ JS.mixin(EventMouse.prototype, {
},
/**
- * Returns the previous touch location.
+ * !#en Returns the previous touch location.
+ * !#zh 获取鼠标点击在上一次事件时的位置对象,对象包含 x 和 y 属性。
* @method getPreviousLocation
* @return {Vec2}
*/
@@ -155,7 +161,8 @@ JS.mixin(EventMouse.prototype, {
},
/**
- * Returns the delta distance from the previous location to current location.
+ * !#en Returns the delta distance from the previous location to current location.
+ * !#zh 获取鼠标距离上一次事件移动的距离对象,对象包含 x 和 y 属性。
* @method getDelta
* @return {Vec2}
*/
@@ -164,8 +171,9 @@ JS.mixin(EventMouse.prototype, {
},
/**
- * Returns the X axis delta distance from the previous location to current location.
- * @method getDeltaX
+ * !#en Returns the X axis delta distance from the previous location to current location.
+ * !#zh 获取鼠标距离上一次事件移动的 X 轴距离。
+ * @method getDeltaX。
* @return {Number}
*/
getDeltaX: function () {
@@ -173,7 +181,8 @@ JS.mixin(EventMouse.prototype, {
},
/**
- * Returns the Y axis delta distance from the previous location to current location.
+ * !#en Returns the Y axis delta distance from the previous location to current location.
+ * !#zh 获取鼠标距离上一次事件移动的 Y 轴距离。
* @method getDeltaY
* @return {Number}
*/
@@ -182,7 +191,8 @@ JS.mixin(EventMouse.prototype, {
},
/**
- * Sets mouse button.
+ * !#en Sets mouse button.
+ * !#zh 设置鼠标按键。
* @method setButton
* @param {Number} button
*/
@@ -191,7 +201,8 @@ JS.mixin(EventMouse.prototype, {
},
/**
- * Returns mouse button.
+ * !#en Returns mouse button.
+ * !#zh 获取鼠标按键。
* @method getButton
* @returns {Number}
*/
@@ -200,7 +211,8 @@ JS.mixin(EventMouse.prototype, {
},
/**
- * Returns location X axis data.
+ * !#en Returns location X axis data.
+ * !#zh 获取鼠标当前位置 X 轴。
* @method getLocationX
* @returns {Number}
*/
@@ -209,7 +221,8 @@ JS.mixin(EventMouse.prototype, {
},
/**
- * Returns location Y axis data.
+ * !#en Returns location Y axis data.
+ * !#zh 获取鼠标当前位置 Y 轴。
* @method getLocationY
* @returns {Number}
*/
@@ -220,99 +233,113 @@ JS.mixin(EventMouse.prototype, {
//Inner event types of MouseEvent
/**
- * The none event code of mouse event.
+ * !#en The none event code of mouse event.
+ * !#zh 无。
* @constant
* @type {Number}
*/
EventMouse.NONE = 0;
/**
- * The event type code of mouse down event.
+ * !#en The event type code of mouse down event.
+ * !#zh 鼠标按下事件。
* @constant
* @type {Number}
*/
EventMouse.DOWN = 1;
/**
- * The event type code of mouse up event.
+ * !#en The event type code of mouse up event.
+ * !#zh 鼠标按下后释放事件。
* @constant
* @type {Number}
*/
EventMouse.UP = 2;
/**
- * The event type code of mouse move event.
+ * !#en The event type code of mouse move event.
+ * !#zh 鼠标移动事件。
* @constant
* @type {Number}
*/
EventMouse.MOVE = 3;
/**
- * The event type code of mouse scroll event.
+ * !#en The event type code of mouse scroll event.
+ * !#zh 鼠标滚轮事件。
* @constant
* @type {Number}
*/
EventMouse.SCROLL = 4;
/**
- * The tag of Mouse left button
+ * !#en The tag of Mouse left button.
+ * !#zh 鼠标左键的标签。
* @constant
* @type {Number}
*/
EventMouse.BUTTON_LEFT = 0;
/**
- * The tag of Mouse right button (The right button number is 2 on browser)
+ * !#en The tag of Mouse right button (The right button number is 2 on browser).
+ * !#zh 鼠标右键的标签。
* @constant
* @type {Number}
*/
EventMouse.BUTTON_RIGHT = 2;
/**
- * The tag of Mouse middle button (The right button number is 1 on browser)
+ * !#en The tag of Mouse middle button (The right button number is 1 on browser).
+ * !#zh 鼠标中键的标签。
* @constant
* @type {Number}
*/
EventMouse.BUTTON_MIDDLE = 1;
/**
- * The tag of Mouse button 4
+ * !#en The tag of Mouse button 4.
+ * !#zh 鼠标按键 4 的标签。
* @constant
* @type {Number}
*/
EventMouse.BUTTON_4 = 3;
/**
- * The tag of Mouse button 5
+ * !#en The tag of Mouse button 5.
+ * !#zh 鼠标按键 5 的标签。
* @constant
* @type {Number}
*/
EventMouse.BUTTON_5 = 4;
/**
- * The tag of Mouse button 6
+ * !#en The tag of Mouse button 6.
+ * !#zh 鼠标按键 6 的标签。
* @constant
* @type {Number}
*/
EventMouse.BUTTON_6 = 5;
/**
- * The tag of Mouse button 7
+ * !#en The tag of Mouse button 7.
+ * !#zh 鼠标按键 7 的标签。
* @constant
* @type {Number}
*/
EventMouse.BUTTON_7 = 6;
/**
- * The tag of Mouse button 8
+ * !#en The tag of Mouse button 8.
+ * !#zh 鼠标按键 8 的标签。
* @constant
* @type {Number}
*/
EventMouse.BUTTON_8 = 7;
/**
- * The touch event
+ * !#en The touch event
+ * !#zh 触摸事件
* @class Event.EventTouch
* @constructor
* @extends Event
- * @param {Array} [touchArr=[]] - The array of the touches
- * @param {Boolean} [bubbles=false] - A boolean indicating whether the event bubbles up through the tree or not
+ * @param {Array} touchArr - The array of the touches
+ * @param {Boolean} bubbles - A boolean indicating whether the event bubbles up through the tree or not
*/
var EventTouch = function (touchArr, bubbles) {
cc.Event.call(this, cc.Event.TOUCH, bubbles);
@@ -324,7 +351,8 @@ var EventTouch = function (touchArr, bubbles) {
JS.extend(EventTouch, cc.Event);
JS.mixin(EventTouch.prototype, {
/**
- * Returns event code.
+ * !#en Returns event code.
+ * !#zh 获取事件类型。
* @method getEventCode
* @returns {Number}
*/
@@ -333,7 +361,8 @@ JS.mixin(EventTouch.prototype, {
},
/**
- * Returns touches of event.
+ * !#en Returns touches of event.
+ * !#zh 获取触摸点的列表。
* @method getTouches
* @returns {Array}
*/
@@ -350,7 +379,8 @@ JS.mixin(EventTouch.prototype, {
},
/**
- * Sets touch location.
+ * !#en Sets touch location.
+ * !#zh 设置当前触点位置
* @method setLocation
* @param {Number} x
* @param {Number} y
@@ -360,7 +390,8 @@ JS.mixin(EventTouch.prototype, {
},
/**
- * Returns touch location.
+ * !#en Returns touch location.
+ * !#zh 获取触点位置。
* @method getLocation
* @return {Vec2} location
*/
@@ -369,7 +400,8 @@ JS.mixin(EventTouch.prototype, {
},
/**
- * Returns the current touch location in screen coordinates.
+ * !#en Returns the current touch location in screen coordinates.
+ * !#zh 获取当前触点在游戏窗口中的位置。
* @method getLocationInView
* @return {Vec2}
*/
@@ -378,7 +410,8 @@ JS.mixin(EventTouch.prototype, {
},
/**
- * Returns the previous touch location.
+ * !#en Returns the previous touch location.
+ * !#zh 获取触点在上一次事件时的位置对象,对象包含 x 和 y 属性。
* @method getPreviousLocation
* @return {Vec2}
*/
@@ -387,7 +420,8 @@ JS.mixin(EventTouch.prototype, {
},
/**
- * Returns the start touch location.
+ * !#en Returns the start touch location.
+ * !#zh 获获取触点落下时的位置对象,对象包含 x 和 y 属性。
* @method getStartLocation
* @returns {Vec2}
*/
@@ -396,7 +430,8 @@ JS.mixin(EventTouch.prototype, {
},
/**
- * Returns the id of cc.Touch.
+ * !#en Returns the id of cc.Touch.
+ * !#zh 触点的标识 ID,可以用来在多点触摸中跟踪触点。
* @method getID
* @return {Number}
*/
@@ -405,7 +440,8 @@ JS.mixin(EventTouch.prototype, {
},
/**
- * Returns the delta distance from the previous location to current location.
+ * !#en Returns the delta distance from the previous location to current location.
+ * !#zh 获取触点距离上一次事件移动的距离对象,对象包含 x 和 y 属性。
* @method getDelta
* @return {Vec2}
*/
@@ -414,7 +450,8 @@ JS.mixin(EventTouch.prototype, {
},
/**
- * Returns the X axis delta distance from the previous location to current location.
+ * !#en Returns the X axis delta distance from the previous location to current location.
+ * !#zh 获取触点距离上一次事件移动的 x 轴距离。
* @method getDeltaX
* @return {Number}
*/
@@ -423,7 +460,8 @@ JS.mixin(EventTouch.prototype, {
},
/**
- * Returns the Y axis delta distance from the previous location to current location.
+ * !#en Returns the Y axis delta distance from the previous location to current location.
+ * !#zh 获取触点距离上一次事件移动的 y 轴距离。
* @method getDeltaY
* @return {Number}
*/
@@ -432,7 +470,8 @@ JS.mixin(EventTouch.prototype, {
},
/**
- * Returns location X axis data.
+ * !#en Returns location X axis data.
+ * !#zh 获取当前触点 X 轴位置。
* @method getLocationX
* @returns {Number}
*/
@@ -441,7 +480,8 @@ JS.mixin(EventTouch.prototype, {
},
/**
- * Returns location Y axis data.
+ * !#en Returns location Y axis data.
+ * !#zh 获取当前触点 Y 轴位置。
* @method getLocationY
* @returns {Number}
*/
@@ -451,60 +491,50 @@ JS.mixin(EventTouch.prototype, {
});
/**
- * The maximum touch numbers
+ * !#en The maximum touch numbers
+ * !#zh 最大触摸数量。
* @constant
* @type {Number}
*/
EventTouch.MAX_TOUCHES = 5;
/**
- * The event type code of touch began event.
+ * !#en The event type code of touch began event.
+ * !#zh 开始触摸事件
* @constant
* @type {Number}
*/
EventTouch.BEGAN = 0;
/**
- * The event type code of touch moved event.
+ * !#en The event type code of touch moved event.
+ * !#zh 触摸后移动事件
* @constant
* @type {Number}
*/
EventTouch.MOVED = 1;
/**
- * The event type code of touch ended event.
+ * !#en The event type code of touch ended event.
+ * !#zh 结束触摸事件
* @constant
* @type {Number}
*/
EventTouch.ENDED = 2;
/**
- * The event type code of touch cancelled event.
+ * !#en The event type code of touch cancelled event.
+ * !#zh 取消触摸事件
* @constant
* @type {Number}
*/
EventTouch.CANCELED = 3;
/**
- * Focus change event for UI widget
- * @class Event.EventFocus
- * @constructor
- * @extends Event
- * @param {Widget} widgetLoseFocus
- * @param {Widget} widgetGetFocus
- * @param {Boolean} [bubbles=false] - A boolean indicating whether the event bubbles up through the tree or not
- */
-EventFocus = function (widgetGetFocus, widgetLoseFocus, bubbles) {
- cc.Event.call(this, cc.Event.FOCUS, bubbles);
- this._widgetGetFocus = widgetGetFocus;
- this._widgetLoseFocus = widgetLoseFocus;
-};
-JS.extend(EventFocus, cc.Event);
-
-/**
- * The acceleration event
+ * !#en The acceleration event
+ * !#zh 加速度事件
* @class Event.EventAcceleration
* @extends Event
* @constructor
* @param {Object} acc - The acceleration
- * @param {Boolean} [bubbles=false] - A boolean indicating whether the event bubbles up through the tree or not
+ * @param {Boolean} bubbles - A boolean indicating whether the event bubbles up through the tree or not
*/
EventAcceleration = function (acc, bubbles) {
cc.Event.call(this, Event.ACCELERATION, bubbles);
@@ -513,13 +543,14 @@ EventAcceleration = function (acc, bubbles) {
JS.extend(EventAcceleration, cc.Event);
/**
- * The keyboard event
+ * !#en The keyboard event
+ * !#zh 键盘事件
* @class Event.EventKeyboard
* @extends Event
* @constructor
* @param {Number} keyCode - The key code of which triggered this event
* @param {Boolean} isPressed - A boolean indicating whether the key have been pressed
- * @param {Boolean} [bubbles=false] - A boolean indicating whether the event bubbles up through the tree or not
+ * @param {Boolean} bubbles - A boolean indicating whether the event bubbles up through the tree or not
*/
EventKeyboard = function (keyCode, isPressed, bubbles) {
cc.Event.call(this, Event.KEYBOARD, bubbles);
@@ -530,7 +561,6 @@ JS.extend(EventKeyboard, cc.Event);
cc.Event.EventMouse = EventMouse;
cc.Event.EventTouch = EventTouch;
-cc.Event.EventFocus = EventFocus;
cc.Event.EventAcceleration = EventAcceleration;
cc.Event.EventKeyboard = EventKeyboard;
diff --git a/cocos2d/core/event-manager/CCTouch.js b/cocos2d/core/event-manager/CCTouch.js
index 2a8e9be731..821f16f342 100644
--- a/cocos2d/core/event-manager/CCTouch.js
+++ b/cocos2d/core/event-manager/CCTouch.js
@@ -24,7 +24,8 @@
****************************************************************************/
/**
- * The touch event class
+ * !#en The touch event class
+ * !#zh 封装了触摸相关的信息。
* @class Touch
*
* @param {Number} x
@@ -43,7 +44,8 @@ cc.Touch = cc._Class.extend(/** @lends cc.Touch# */{
},
/**
- * Returns the current touch location in OpenGL coordinates.
+ * !#en Returns the current touch location in OpenGL coordinates.、
+ * !#zh 获取当前触点位置。
* @method getLocation
* @return {Vec2}
*/
@@ -54,7 +56,8 @@ cc.Touch = cc._Class.extend(/** @lends cc.Touch# */{
},
/**
- * Returns X axis location value.
+ * !#en Returns X axis location value.
+ * !#zh 获取当前触点 X 轴位置。
* @method getLocationX
* @returns {Number}
*/
@@ -63,7 +66,8 @@ cc.Touch = cc._Class.extend(/** @lends cc.Touch# */{
},
/**
- * Returns Y axis location value.
+ * !#en Returns Y axis location value.
+ * !#zh 获取当前触点 Y 轴位置。
* @method getLocationY
* @returns {Number}
*/
@@ -72,7 +76,8 @@ cc.Touch = cc._Class.extend(/** @lends cc.Touch# */{
},
/**
- * Returns the previous touch location in OpenGL coordinates.
+ * !#en Returns the previous touch location in OpenGL coordinates.
+ * !#zh 获取触点在上一次事件时的位置对象,对象包含 x 和 y 属性。
* @method getPreviousLocation
* @return {Vec2}
*/
@@ -83,7 +88,8 @@ cc.Touch = cc._Class.extend(/** @lends cc.Touch# */{
},
/**
- * Returns the start touch location in OpenGL coordinates.
+ * !#en Returns the start touch location in OpenGL coordinates.
+ * !#zh 获获取触点落下时的位置对象,对象包含 x 和 y 属性。
* @method getStartLocation
* @returns {Vec2}
*/
@@ -94,7 +100,8 @@ cc.Touch = cc._Class.extend(/** @lends cc.Touch# */{
},
/**
- * Returns the delta distance from the previous touche to the current one in screen coordinates.
+ * !#en Returns the delta distance from the previous touche to the current one in screen coordinates.
+ * !#zh 获取触点距离上一次事件移动的距离对象,对象包含 x 和 y 属性。
* @method getDelta
* @return {Vec2}
*/
@@ -103,7 +110,8 @@ cc.Touch = cc._Class.extend(/** @lends cc.Touch# */{
},
/**
- * Returns the current touch location in screen coordinates.
+ * !#en Returns the current touch location in screen coordinates.
+ * !#zh 获取当前事件在游戏窗口内的坐标位置对象,对象包含 x 和 y 属性。
* @method getLocationInView
* @return {Vec2}
*/
@@ -112,7 +120,8 @@ cc.Touch = cc._Class.extend(/** @lends cc.Touch# */{
},
/**
- * Returns the previous touch location in screen coordinates.
+ * !#en Returns the previous touch location in screen coordinates.
+ * !#zh 获取触点在上一次事件时在游戏窗口中的位置对象,对象包含 x 和 y 属性。
* @method getPreviousLocationInView
* @return {Vec2}
*/
@@ -121,7 +130,8 @@ cc.Touch = cc._Class.extend(/** @lends cc.Touch# */{
},
/**
- * Returns the start touch location in screen coordinates.
+ * !#en Returns the start touch location in screen coordinates.
+ * !#zh 获取触点落下时在游戏窗口中的位置对象,对象包含 x 和 y 属性。
* @method getStartLocationInView
* @return {Vec2}
*/
@@ -130,7 +140,8 @@ cc.Touch = cc._Class.extend(/** @lends cc.Touch# */{
},
/**
- * Returns the id of cc.Touch.
+ * !#en Returns the id of cc.Touch.
+ * !#zh 触点的标识 ID,可以用来在多点触摸中跟踪触点。
* @method getID
* @return {Number}
*/
@@ -139,7 +150,8 @@ cc.Touch = cc._Class.extend(/** @lends cc.Touch# */{
},
/**
- * Sets information to touch.
+ * !#en Sets information to touch.
+ * !#zh 设置触摸相关的信息。用于监控触摸事件。
* @method setTouchInfo
* @param {Number} id
* @param {Number} x
diff --git a/cocos2d/core/event/event-target.js b/cocos2d/core/event/event-target.js
index 537f0b65fb..a55b208d8a 100644
--- a/cocos2d/core/event/event-target.js
+++ b/cocos2d/core/event/event-target.js
@@ -98,6 +98,7 @@ var _doSendEvent = function (owner, event) {
};
/**
+ * !#en
* EventTarget is an object to which an event is dispatched when something has occurred.
* Entity are the most common event targets, but other objects can be event targets too.
*
@@ -116,6 +117,10 @@ var _doSendEvent = function (owner, event) {
* - _getCapturingTargets
* - _getBubblingTargets
*
+ * !#zh
+ * 事件目标是事件触发时,分派的事件对象,Node 是最常见的事件目标,
+ * 但是其他对象也可以是事件目标。
+ *
* @class EventTarget
*/
var EventTarget = function () {
@@ -139,8 +144,8 @@ var EventTarget = function () {
JS.mixin(EventTarget.prototype, {
/**
- * Checks whether the EventTarget object has any callback registered for a specific type of event.
- *
+ * !#en Checks whether the EventTarget object has any callback registered for a specific type of event.
+ * !#zh 检查事件目标对象是否为不特定类型的事件注册的回调。
* @param {String} type - The type of event.
* @param {Boolean} A value of true if a callback of the specified type is registered; false otherwise.
*/
@@ -153,20 +158,27 @@ JS.mixin(EventTarget.prototype, {
},
/**
+ * !#en
* Register an callback of a specific event type on the EventTarget.
* This method is merely an alias to addEventListener.
+ * !#zh
+ * 注册事件目标的特定事件类型回调,仅仅是 addEventListener 的别名。
*
* @method on
* @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 {Object} [target] - The target to invoke the callback, can be null
- * @param {Boolean} [useCapture=false] - When set to true, the capture argument prevents callback
+ * @param {Object} target - The target to invoke the callback, can be null
+ * @param {Boolean} useCapture - 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.
+ * @exmaple
+ * node.on(cc.Node.EventType.TOUCH_END, function (event) {
+ * cc.log("this is callback");
+ * }, node);
*/
on: function (type, callback, target, useCapture) {
// Accept also patameters like: (type, callback, useCapture)
@@ -196,17 +208,27 @@ JS.mixin(EventTarget.prototype, {
},
/**
+ * !#en
* Removes the callback previously registered with the same type, callback, target and or useCapture.
* This method is merely an alias to removeEventListener.
+ * !#zh
+ * 删除之前与同类型,回调,目标或 useCapture 注册的回调,仅仅是 removeEventListener 的别名。
*
* @method off
* @param {String} type - A string representing the event type being removed.
* @param {Function} callback - The callback to remove.
- * @param {Object} [target] - The target to invoke the callback, if it's not given, only callback without target will be removed
- * @param {Boolean} [useCapture=false] - Specifies whether the callback being removed was registered as a capturing callback or not.
+ * @param {Object} target - The target to invoke the callback, if it's not given, only callback without target will be removed
+ * @param {Boolean} useCapture - Specifies whether the callback being removed was registered as a capturing callback or not.
* If not specified, useCapture defaults to false. If a callback was registered twice,
* 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.
+ * @exmaple
+ * // register touchEnd eventListener
+ * var touchEnd = node.on(cc.Node.EventType.TOUCH_END, function (event) {
+ * cc.log("this is callback");
+ * }, node);
+ * // remove touchEnd eventListener
+ * node.off(cc.Node.EventType.TOUCH_END, touchEnd, node);
*/
off: function (type, callback, target, useCapture) {
// Accept also patameters like: (type, callback, useCapture)
@@ -230,8 +252,8 @@ JS.mixin(EventTarget.prototype, {
},
/**
- * Removes all callbacks previously registered with the same target.
- *
+ * !#en Removes all callbacks previously registered with the same target.
+ * !#zh 删除指定目标上的所有注册回调。
* @method targetOff
* @param {Object} target - The target to be searched for all related callbacks
*/
@@ -245,18 +267,26 @@ JS.mixin(EventTarget.prototype, {
},
/**
- * Register an callback of a specific event type on the EventTarget, the callback will remove itself after the first time it is triggered.
+ * !#en
+ * Register an callback of a specific event type on the EventTarget,
+ * the callback will remove itself after the first time it is triggered.
+ * !#zh
+ * 注册事件目标的特定事件类型回调,回调会在第一时间被触发后删除自身。
*
* @method once
* @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 {Object} [target] - The target to invoke the callback, can be null
- * @param {Boolean} [useCapture=false] - When set to true, the capture argument prevents callback
+ * @param {Object} target - The target to invoke the callback, can be null
+ * @param {Boolean} useCapture - 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.
+ * @exmaple
+ * node.once(cc.Node.EventType.TOUCH_END, function (event) {
+ * cc.log("this is callback");
+ * }, node);
*/
once: function (type, callback, target, useCapture) {
var self = this;
@@ -268,7 +298,10 @@ JS.mixin(EventTarget.prototype, {
},
/**
- * Dispatches an event into the event flow. The event target is the EventTarget object upon which the dispatchEvent() method is called.
+ * !#en
+ * Dispatches an event into the event flow.
+ * The event target is the EventTarget object upon which the dispatchEvent() method is called.
+ * !#zh 分发事件到事件流中。
*
* @method dispatchEvent
* @param {Event} event - The Event object that is dispatched into the event flow
@@ -284,12 +317,15 @@ JS.mixin(EventTarget.prototype, {
},
/**
+ * !#en
* Send an event to this object directly, this method will not propagate the event to any other objects.
* The event will be created from the supplied message, you can get the "detail" argument from event.detail.
+ * !#zh
+ * 该对象直接发送事件, 这种方法不会对事件传播到任何其他对象。
*
* @method emit
* @param {String} message - the message to send
- * @param {any} [detail] - whatever argument the message needs
+ * @param {*} [detail] - whatever argument the message needs
*/
emit: function (message, detail) {
if ( typeof message === 'string' ) {
@@ -302,7 +338,7 @@ JS.mixin(EventTarget.prototype, {
}
},
- /**
+ /*
* Get whether the target is active for events.
* The name is for avoiding conflict with user defined functions.
*
@@ -315,7 +351,7 @@ JS.mixin(EventTarget.prototype, {
return true;
},
- /**
+ /*
* Get all the targets listening to the supplied type of event in the target's capturing phase.
* The capturing phase comprises the journey from the root to the last node BEFORE the event target's node.
* The result should save in the array parameter, and MUST SORT from child nodes to parent nodes.
@@ -330,7 +366,7 @@ JS.mixin(EventTarget.prototype, {
},
- /**
+ /*
* Get all the targets listening to the supplied type of event in the target's bubbling phase.
* The bubbling phase comprises any SUBSEQUENT nodes encountered on the return trip to the root of the tree.
* The result should save in the array parameter, and MUST SORT from child nodes to parent nodes.
diff --git a/cocos2d/core/event/event.js b/cocos2d/core/event/event.js
index bd431568a8..6ff2d261ab 100644
--- a/cocos2d/core/event/event.js
+++ b/cocos2d/core/event/event.js
@@ -26,47 +26,53 @@
var JS = require("../platform/js");
/**
- * Base class of all kinds of events.
+ * !#en Base class of all kinds of events.
+ * !#zh 包含事件相关信息的对象。
* @class Event
* @constructor
*/
/**
* @method Event
- * @param {string} type - The name of the event (case-sensitive), e.g. "click", "fire", or "submit"
- * @param {boolean} [bubbles=false] - A boolean indicating whether the event bubbles up through the tree or not
+ * @param {String} type - The name of the event (case-sensitive), e.g. "click", "fire", or "submit"
+ * @param {Boolean} bubbles - A boolean indicating whether the event bubbles up through the tree or not
* @return {Event}
*/
cc.Event = function(type, bubbles) {
/**
- * The name of the event (case-sensitive), e.g. "click", "fire", or "submit".
+ * !#en The name of the event (case-sensitive), e.g. "click", "fire", or "submit".
+ * !#zh 事件类型。
* @property type
* @type {String}
*/
this.type = type;
/**
- * Indicate whether the event bubbles up through the tree or not.
+ * !#en Indicate whether the event bubbles up through the tree or not.
+ * !#zh 表示该事件是否进行冒泡。
* @property bubbles
* @type {Boolean}
*/
this.bubbles = bubbles || false;
/**
- * A reference to the target to which the event was originally dispatched.
+ * !#en A reference to the target to which the event was originally dispatched.
+ * !#zh 最初事件触发的目标
* @property target
* @type {Object}
*/
this.target = null;
/**
- * A reference to the currently registered target for the event.
+ * !#en A reference to the currently registered target for the event.
+ * !#zh 当前目标
* @property currentTarget
* @type {Object}
*/
this.currentTarget = null;
/**
+ * !#en
* Indicates which phase of the event flow is currently being evaluated.
* Returns an integer value represented by 4 constants:
* - Event.NONE = 0
@@ -75,13 +81,13 @@ cc.Event = function(type, bubbles) {
* - Event.BUBBLING_PHASE = 3
* The phases are explained in the [section 3.1, Event dispatch and DOM event flow]
* (http://www.w3.org/TR/DOM-Level-3-Events/#event-flow), of the DOM Level 3 Events specification.
- *
+ * !#zh 事件阶段
* @property eventPhase
* @type {Number}
*/
this.eventPhase = 0;
- /**
+ /*
* Indicates whether or not event.preventDefault() has been called on the event.
* @property _defaultPrevented
* @type {Boolean}
@@ -89,7 +95,7 @@ cc.Event = function(type, bubbles) {
*/
this._defaultPrevented = false;
- /**
+ /*
* Indicates whether or not event.stopPropagation() has been called on the event.
* @property _propagationStopped
* @type {Boolean}
@@ -97,7 +103,7 @@ cc.Event = function(type, bubbles) {
*/
this._propagationStopped = false;
- /**
+ /*
* Indicates whether or not event.stopPropagationImmediate() has been called on the event.
* @property _propagationImmediateStopped
* @type {Boolean}
@@ -109,7 +115,8 @@ cc.Event.prototype = {
constructor: cc.Event,
/**
- * Reset the event for being stored in the object pool.
+ * !#en Reset the event for being stored in the object pool.
+ * !#zh 重置对象池中存储的事件。
* @method unuse
* @returns {String}
*/
@@ -124,7 +131,8 @@ cc.Event.prototype = {
},
/**
- * Reuse the event for being used again by the object pool.
+ * !#en Reuse the event for being used again by the object pool.
+ * !#zh 用于对象池再次使用的事件。
* @method reuse
* @returns {String}
*/
@@ -134,7 +142,9 @@ cc.Event.prototype = {
},
/**
+ * !#en
* If invoked when the cancelable attribute value is true, signals to the operation that caused event to be dispatched that it needs to be canceled.
+ * !#zh 捕获阶段时,阻止传递给最终目标。
* @method preventDefault
*/
preventDefault: function () {
@@ -142,7 +152,8 @@ cc.Event.prototype = {
},
/**
- * Stops propagation for current event.
+ * !#en Stops propagation for current event.
+ * !#zh 停止传递当前事件。
* @method stopPropagation
*/
stopPropagation: function () {
@@ -150,8 +161,9 @@ cc.Event.prototype = {
},
/**
- * Stops propagation for current event immediately,
+ * !#en Stops propagation for current event immediately,
* the event won't even be dispatched to the listeners attached in the current target.
+ * !#zh 立即停止当前事件的传递,事件甚至不会被分派到所连接的当前目标。
* @method stopPropagationImmediate
*/
stopPropagationImmediate: function () {
@@ -159,7 +171,8 @@ cc.Event.prototype = {
},
/**
- * Checks whether the event has been stopped.
+ * !#en Checks whether the event has been stopped.
+ * !#zh 检查该事件是否已经停止传递.
* @method isStopped
* @returns {Boolean}
*/
@@ -168,11 +181,13 @@ cc.Event.prototype = {
},
/**
+ * !#en
*
* Gets current target of the event
* note: It only be available when the event listener is associated with node.
* It returns 0 when the listener is associated with fixed priority.
*
+ * !#zh 获取当前目标节点
* @method getCurrentTarget
* @returns {Node} The target with which the event associates.
*/
@@ -181,7 +196,8 @@ cc.Event.prototype = {
},
/**
- * Gets the event type.
+ * !#en Gets the event type.
+ * !#zh 获取事件类型
* @method getType
* @returns {String}
*/
@@ -192,7 +208,8 @@ cc.Event.prototype = {
//event type
/**
- * Code for event without type.
+ * !#en Code for event without type.
+ * !#zh 没有类型的事件
* @property NO_TYPE
* @final
* @type {string}
@@ -201,31 +218,38 @@ cc.Event.NO_TYPE = 'no_type';
//event phase
/**
- * Events not currently dispatched are in this phase
+ * !#en Events not currently dispatched are in this phase
+ * !#zh 尚未派发事件阶段
* @property NONE
* @type {Number}
* @final
*/
cc.Event.NONE = 0;
/**
+ * !#en
* The capturing phase comprises the journey from the root to the last node before the event target's node
* see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow
+ * !#zh 捕获阶段,包括事件目标节点之前从根节点到最后一个节点的过程。
* @property CAPTURING_PHASE
* @type {Number}
* @final
*/
cc.Event.CAPTURING_PHASE = 1;
/**
+ * !#en
* The target phase comprises only the event target node
* see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow
+ * !#zh 目标阶段仅包括事件目标节点。
* @property AT_TARGET
* @type {Number}
* @final
*/
cc.Event.AT_TARGET = 2;
/**
+ * !#en
* The bubbling phase comprises any subsequent nodes encountered on the return trip to the root of the hierarchy
* see http://www.w3.org/TR/DOM-Level-3-Events/#event-flow
+ * !#zh 冒泡阶段, 包括回程遇到到层次根节点的任何后续节点。
* @property BUBBLING_PHASE
* @type {Number}
* @final
@@ -233,7 +257,8 @@ cc.Event.AT_TARGET = 2;
cc.Event.BUBBLING_PHASE = 3;
/**
- * The Custom event
+ * !#en The Custom event
+ * !#zh 自定义事件
* @class Event.EventCustom
* @constructor
* @extends Event
@@ -242,14 +267,15 @@ cc.Event.BUBBLING_PHASE = 3;
/**
* @method EventCustom
* @param {String} type - The name of the event (case-sensitive), e.g. "click", "fire", or "submit"
- * @param {Boolean} [bubbles=false] - A boolean indicating whether the event bubbles up through the tree or not
+ * @param {Boolean} bubbles - A boolean indicating whether the event bubbles up through the tree or not
* @return {EventCustom}
*/
var EventCustom = function (type, bubbles) {
cc.Event.call(this, type, bubbles);
/**
- * A reference to the detailed data of the event
+ * !#en A reference to the detailed data of the event
+ * !#zh 事件的详细数据
* @property detail
* @type {Object}
*/
@@ -259,7 +285,8 @@ var EventCustom = function (type, bubbles) {
JS.extend(EventCustom, cc.Event);
JS.mixin(EventCustom.prototype, {
/**
- * Sets user data
+ * !#en Sets user data
+ * !#zh 设置用户数据
* @method setUserData
* @param {*} data
*/
@@ -268,7 +295,8 @@ JS.mixin(EventCustom.prototype, {
},
/**
- * Gets user data
+ * !#en Gets user data
+ * !#zh 获取用户数据
* @method getUserData
* @returns {*}
*/
@@ -277,7 +305,8 @@ JS.mixin(EventCustom.prototype, {
},
/**
- * Gets event name
+ * !#en Gets event name
+ * !#zh 获取事件名称
* @method getEventName
* @returns {String}
*/
diff --git a/cocos2d/core/label/CCSGLabel.js b/cocos2d/core/label/CCSGLabel.js
index cad94feee8..4452fe7eb9 100644
--- a/cocos2d/core/label/CCSGLabel.js
+++ b/cocos2d/core/label/CCSGLabel.js
@@ -109,6 +109,7 @@ _ccsg.Label = _ccsg.Node.extend({
_vAlign: cc.VerticalTextAlignment.TOP, //0 bottom,1 center, 2 top
_string: "",
_fontSize: 40,
+ _drawFontsize: 40,
_overFlow: 0, //see _ccsg.Label.Overflow
_isWrapText: true,
_spacingX: 0,
@@ -155,7 +156,6 @@ _ccsg.Label = _ccsg.Node.extend({
this._lettersInfo = [];
this._linesWidth = [];
this._linesOffsetX = [];
- this._bmFontSize = 0;
this._textDesiredHeight = 0;
this._letterOffsetY = 0;
this._tailoredTopY = 0;
@@ -235,6 +235,7 @@ _ccsg.Label = _ccsg.Node.extend({
}
this._isWrapText = enabled;
this._rescaleWithOriginalFontSize();
+
this._notifyLabelSkinDirty();
},
@@ -246,7 +247,7 @@ _ccsg.Label = _ccsg.Node.extend({
},
setFontSize: function(fntSize) {
this._fontSize = fntSize;
- this._bmFontSize = fntSize;
+ this._drawFontsize = fntSize;
this._notifyLabelSkinDirty();
},
@@ -658,19 +659,16 @@ cc.BMFontHelper = {
this._maxLineWidth = newWidth;
- if (this._labelType === _ccsg.Label.Type.BMFont && this._overFlow === _ccsg.Label.Overflow.SHRINK) {
- if (this._bmFontSize > 0) {
- this._restoreFontSize();
- }
+ if (this._drawFontsize > 0) {
+ this._restoreFontSize();
}
+
this._notifyLabelSkinDirty();
}
},
_restoreFontSize: function() {
- if (this._labelType === _ccsg.Label.Type.BMFont) {
- this._fontSize = this._bmFontSize;
- }
+ this._fontSize = this._drawFontsize;
},
_multilineTextWrap: function(nextTokenFunc) {
@@ -895,25 +893,23 @@ cc.BMFontHelper = {
_scaleFontSizeDown: function(fontSize) {
var shouldUpdateContent = true;
- //1 is BMFont
if (this._labelType === _ccsg.Label.Type.BMFont) {
if (!fontSize) {
fontSize = 0.1;
shouldUpdateContent = false;
}
this._fontSize = fontSize;
- }
- if (shouldUpdateContent) {
- this._updateContent();
+
+ if (shouldUpdateContent) {
+ this._updateContent();
+ }
}
},
_updateContent: function() {
- var updateFinished = true;
-
if (this._fontAtlas) {
this._computeHorizontalKerningForText(this._string);
- updateFinished = this._alignText();
+ this._alignText();
}
},
@@ -1057,8 +1053,12 @@ cc.BMFontHelper = {
_rescaleWithOriginalFontSize: function() {
var renderingFontSize = this.getFontSize();
- if (this._bmFontSize - renderingFontSize >= 1 && this._overFlow === _ccsg.Label.Overflow.SHRINK) {
- this._scaleFontSizeDown(this._bmFontSize);
+ if (this._drawFontsize - renderingFontSize >= 1 && this._overFlow === _ccsg.Label.Overflow.SHRINK) {
+ if(this._labelType === _ccsg.Label.Type.BMFont) {
+ this._scaleFontSizeDown(this._drawFontsize);
+ } else {
+ this._fontSize = this._drawFontsize;
+ }
}
},
diff --git a/cocos2d/core/label/CCSGLabelCanvasRenderCmd.js b/cocos2d/core/label/CCSGLabelCanvasRenderCmd.js
index 28a557549b..363a5a8ef7 100644
--- a/cocos2d/core/label/CCSGLabelCanvasRenderCmd.js
+++ b/cocos2d/core/label/CCSGLabelCanvasRenderCmd.js
@@ -85,11 +85,12 @@
proto._getLineHeight = function () {
var nodeSpacingY = this._node.getLineHeight();
+ var node = this._node;
if (nodeSpacingY === 0) {
- nodeSpacingY = this._drawFontsize;
+ nodeSpacingY = node._fontSize;
}
else {
- nodeSpacingY = nodeSpacingY * this._drawFontsize / this._node._fontSize;
+ nodeSpacingY = nodeSpacingY * node._fontSize / node._drawFontsize;
}
//float to integer, much faster than Math.floor
return nodeSpacingY | 0;
@@ -129,6 +130,7 @@
var label_lastEnglish = /[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]+$/;
var label_firsrEnglish = /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]/;
+ //Note: Here the maxWidth is the label's content width.
proto._fragmentText = function (strArr, maxWidth, ctx) {
//check the first character
@@ -218,9 +220,9 @@
proto._calculateLabelFont = function() {
var node = this._node;
var paragraphedStrings = node._string.split('\n');
+ var drawFontize = node._fontSize;
- this._drawFontsize = node._fontSize;
- var fontDesc = this._drawFontsize.toString() + 'px ';
+ var fontDesc = drawFontize.toString() + 'px ';
var fontFamily = node._fontHandle.length === 0 ? 'serif' : node._fontHandle;
fontDesc = fontDesc + fontFamily;
this._labelContext.font = fontDesc;
@@ -237,22 +239,28 @@
totalLength += ((paragraphLength[i] / this._canvasSize.width + 1) | 0) * this._canvasSize.width;
}
var scale = this._canvasSize.width * ((this._canvasSize.height / this._getLineHeight()) | 0) / totalLength;
- this._drawFontsize = (this._drawFontsize * Math.min(Math.sqrt(scale), 1)) | 0;
- fontDesc = this._drawFontsize.toString() + 'px ' + fontFamily;
- this._labelContext.font = fontDesc;
+ node._fontSize = (drawFontize * Math.min(Math.sqrt(scale), 1)) | 0;
+ fontDesc = node._fontSize.toString() + 'px ' + fontFamily;
+
+ this._splitedStrings = [];
+ for (var i = 0; i < paragraphedStrings.length; ++i) {
+ this._splitedStrings = this._splitedStrings.concat(this._fragmentText(paragraphedStrings[i], this._canvasSize.width, this._labelContext));
+ }
}
else {
var maxLength = 0;
var totalHeight = paragraphedStrings.length * this._getLineHeight();
for (i = 0; i < paragraphedStrings.length; ++i) {
- if (maxLength < paragraphLength[i]) maxLength = paragraphLength[i];
+ if (maxLength < paragraphLength[i]) {
+ maxLength = paragraphLength[i];
+ }
}
var scaleX = this._canvasSize.width / maxLength;
var scaleY = this._canvasSize.height / totalHeight;
- this._drawFontsize = (this._drawFontsize * Math.min(1, scaleX, scaleY)) | 0;
- fontDesc = this._drawFontsize.toString() + 'px ' + fontFamily;
+ node._fontSize = (drawFontize * Math.min(1, scaleX, scaleY)) | 0;
+ fontDesc = node._fontSize.toString() + 'px ' + fontFamily;
}
}
@@ -389,7 +397,6 @@
proto._bakeLabel = function () {
var node = this._node;
- this._drawFontsize = node._fontSize;
this._canvasSize = this._calculateCanvasSize();
@@ -451,7 +458,6 @@
this._quad = new cc.V3F_C4B_T2F_Quad();
this._quadDirty = true;
this._splitedStrings = null;
- this._drawFontsize = 0;
this._realRenderingSize = cc.size(-10, -10);
};
diff --git a/cocos2d/core/load-pipeline/CCLoader.js b/cocos2d/core/load-pipeline/CCLoader.js
index 1dee19afc4..cd8ab279a3 100644
--- a/cocos2d/core/load-pipeline/CCLoader.js
+++ b/cocos2d/core/load-pipeline/CCLoader.js
@@ -25,13 +25,14 @@
var JS = require('../platform/js');
var Pipeline = require('./pipeline');
-var urlResolver = require('./url-resolver');
var Downloader = require('./downloader');
var Loader = require('./loader');
+var AssetTable = require('./asset-table');
var callInNextTick = require('../platform/utils').callInNextTick;
var downloader = new Downloader();
var loader = new Loader();
+var resources = new AssetTable();
/**
* Loader for resource loading process. It's a singleton object.
@@ -40,7 +41,6 @@ var loader = new Loader();
* @static
*/
cc.loader = new Pipeline([
- urlResolver,
downloader,
loader
]);
@@ -106,32 +106,42 @@ JS.mixin(cc.loader, {
* The only difference is when user pass a single url as resources, the complete callback will set its result directly as the second parameter.
*
* @example
- * cc.loader.load('a.png', function (err, tex) {
- * cc.log('Result should be a texture: ' + (tex instanceof cc.Texture2D));
- * });
+ * cc.loader.load('a.png', function (err, tex) {
+ * cc.log('Result should be a texture: ' + (tex instanceof cc.Texture2D));
+ * });
+ *
+ * cc.loader.load('http://example.com/a.png', function (err, tex) {
+ * cc.log('Should load a texture from external url: ' + (tex instanceof cc.Texture2D));
+ * });
+ *
+ * cc.loader.load({id: 'http://example.com/getImageREST?file=a.png', type: 'png'}, function (err, tex) {
+ * cc.log('Should load a texture from RESTful API by specify the type: ' + (tex instanceof cc.Texture2D));
+ * });
*
- * // load a.png from resources folder with no extension.
- * cc.loader.load('resources://a', function (err, tex) {
- * cc.log('Result should be a texture: ' + (tex instanceof cc.Texture2D));
- * });
- *
- * cc.loader.load(['a.png', 'b.json'], function (errors, results) {
- * if (errors) {
- * for (var i = 0; i < errors.length; i++) {
- * cc.log('Error url [' + errors[i] + ']: ' + results.getError(errors[i]));
- * }
- * }
- * var aTex = results.getContent('a.png');
- * var bJsonObj = results.getContent('b.json');
- * });
+ * cc.loader.load(['a.png', 'b.json'], function (errors, results) {
+ * if (errors) {
+ * for (var i = 0; i < errors.length; i++) {
+ * cc.log('Error url [' + errors[i] + ']: ' + results.getError(errors[i]));
+ * }
+ * }
+ * var aTex = results.getContent('a.png');
+ * var bJsonObj = results.getContent('b.json');
+ * });
*
* @method load
- * @param {String|Array} resources - Url list in an array.
- * If url starts with "resources://", will load from "resources" folder in your assets.
- * @param {[Function]} progressCallback - Callback invoked when progression change
+ * @param {String|Array} resources - Url list in an array
+ * @param {Function} [progressCallback] - Callback invoked when progression change
* @param {Function} completeCallback - Callback invoked when all resources loaded
*/
load: function(resources, progressCallback, completeCallback) {
+
+ // COMPATIBLE WITH 0.X
+ if (typeof resources === 'string' && resources.startsWith('resources://')) {
+ cc.warn('Sorry, the "resources://" protocol is obsoleted, use cc.loader.loadRes instead please.');
+ this.loadRes(resources.slice('resources://'.length), progressCallback, completeCallback);
+ return;
+ }
+
if (completeCallback === undefined) {
completeCallback = progressCallback;
progressCallback = null;
@@ -227,10 +237,71 @@ JS.mixin(cc.loader, {
}
},
+ _resources: resources,
+ _getResUuid: function (url) {
+ url = cc.url.normalize(url);
+ var uuid = resources.getUuid(url);
+ if ( !uuid ) {
+ var extname = cc.path.extname(url);
+ if (extname) {
+ //cc.warn('Don\'t add extension for "%s".', url);
+ // strip extname
+ url = url.slice(0, - extname.length);
+ uuid = resources.getUuid(url);
+ }
+ }
+ return uuid;
+ },
+
/**
- * Get resource data by id.
- * When you load resources with cc.loader, the url or id passed will be the unique identity of the resource.
- * After loaded, you can acquire them by passing the url or original id to this API.
+ * Load resources from the "resources" folder inside the "assets" folder of your project.
+ *
+ * Note: All asset urls in Creator use forward slashes, urls using backslashes will not work.
+ *
+ * @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.
+ *
+ * @example
+ *
+ * // load the texture (project/assets/resources/imgs/cocos.png) from resources folder with no extension
+ * cc.loader.load('imgs/cocos', function (err, texture) {
+ * if (err) {
+ * cc.error(err.message || err);
+ * return;
+ * }
+ * cc.log('Result should be a texture: ' + (texture instanceof cc.Texture2D));
+ * });
+ */
+ loadRes: function (url, progressCallback, completeCallback) {
+ var uuid = this._getResUuid(url);
+ if (uuid) {
+ this.load(
+ {
+ id: uuid,
+ type: 'uuid',
+ uuid: uuid
+ },
+ progressCallback,
+ completeCallback
+ );
+ }
+ else {
+ callInNextTick(function () {
+ completeCallback.call(null, new Error('Resources url "' + url + '" does not exist.'), null);
+ });
+ }
+ },
+
+ /**
+ * Get resource data by id.
+ * When you load resources with {{#crossLink "loader/load:method"}}{{/crossLink}} or {{#crossLink "loader/loadRes:method"}}{{/crossLink}},
+ * the url will be the unique identity of the resource.
+ * After loaded, you can acquire them by passing the url to this API.
*
* @method getRes
* @param {String} url
@@ -258,6 +329,35 @@ JS.mixin(cc.loader, {
this.removeItem(url);
},
+ /**
+ * Release the loaded cache of asset.
+ *
+ * @method releaseAsset
+ * @param {Asset} asset
+ */
+ releaseAsset: function (asset) {
+ var uuid = asset._uuid;
+ if (uuid) {
+ this.removeItem(uuid);
+ }
+ },
+
+ /**
+ * Release the cache of resource which loaded by {{#crossLink "loader/loadRes:method"}}{{/crossLink}}.
+ *
+ * @method releaseRes
+ * @param {String} url
+ */
+ releaseRes: function (url) {
+ var uuid = this._getResUuid(url);
+ if (uuid) {
+ this.removeItem(uuid);
+ }
+ else {
+ cc.error('Resources url "%s" does not exist.', url);
+ }
+ },
+
/**
* Resource cache of all resources.
*
diff --git a/cocos2d/core/load-pipeline/audio-downloader.js b/cocos2d/core/load-pipeline/audio-downloader.js
index 2d42c7c6ee..00190f3560 100644
--- a/cocos2d/core/load-pipeline/audio-downloader.js
+++ b/cocos2d/core/load-pipeline/audio-downloader.js
@@ -57,7 +57,7 @@ function loadAudioFromExtList (url, typeList, audio, cb){
context['decodeAudioData'](request.response, function (buffer) {
//success
audio.setBuffer(buffer);
- cb(null, audio);
+ cb(null, audio.src);
}, function() {
//error
loadAudioFromExtList(url, typeList, audio, cb);
@@ -81,7 +81,7 @@ function loadAudioFromExtList (url, typeList, audio, cb){
termination = true;
element.pause();
document.body.removeChild(element);
- cb('Audio load timeout : ' + url, audio);
+ cb('Audio load timeout : ' + url, null);
}
}, 8000);
@@ -97,7 +97,7 @@ function loadAudioFromExtList (url, typeList, audio, cb){
element.removeEventListener('canplaythrough', success, false);
element.removeEventListener('error', failure, false);
element.removeEventListener('emptied', emptied, false);
- !termination && cb(null, audio);
+ !termination && cb(null, url);
cbCheck = true;
clearTimeout(timer);
}
@@ -118,7 +118,7 @@ function loadAudioFromExtList (url, typeList, audio, cb){
var emptied = function(){
termination = true;
success();
- cb(null, audio);
+ cb(null, url);
};
element.addEventListener('canplaythrough', success, false);
@@ -170,7 +170,8 @@ function downloadAudio (item, callback) {
}
// hack for audio to be found before loaded
- item.content = audio;
+ item.content = url;
+ item.audio = audio;
loadAudioFromExtList(url, typeList, audio, callback);
}
diff --git a/cocos2d/core/load-pipeline/pipeline.js b/cocos2d/core/load-pipeline/pipeline.js
index 9e2152a699..93930c16a1 100644
--- a/cocos2d/core/load-pipeline/pipeline.js
+++ b/cocos2d/core/load-pipeline/pipeline.js
@@ -445,6 +445,15 @@ JS.mixin(Pipeline.prototype, {
return this._items;
},
+ /**
+ * Returns an item in pipeline.
+ * @method getItems
+ * @return {LoadingItems}
+ */
+ getItem: function (url) {
+ return this._items.map[url];
+ },
+
/**
* Removes an item in pipeline, no matter it's in progress or completed.
* @method removeItem
diff --git a/cocos2d/core/load-pipeline/url-resolver.js b/cocos2d/core/load-pipeline/url-resolver.js
deleted file mode 100644
index 1eabdd3a75..0000000000
--- a/cocos2d/core/load-pipeline/url-resolver.js
+++ /dev/null
@@ -1,101 +0,0 @@
-/****************************************************************************
- Copyright (c) 2013-2016 Chukong Technologies Inc.
-
- http://www.cocos.com
-
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated engine source code (the "Software"), a limited,
- worldwide, royalty-free, non-assignable, revocable and non-exclusive license
- to use Cocos Creator solely to develop games on your target platforms. You shall
- not use Cocos Creator software for developing other software or tools that's
- used for developing games. You are not granted to publish, distribute,
- sublicense, and/or sell copies of Cocos Creator.
-
- The software or tools in this License Agreement are licensed, not sold.
- Chukong Aipu reserves all rights not expressly granted to you.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- THE SOFTWARE.
- ****************************************************************************/
-
-var Pipeline = require('./pipeline');
-var AssetTable = require('./asset-table');
-
-var RESOURCES_PROTOCOL = 'resources://';
-
-Pipeline.UrlResolver = module.exports = {
- id: 'UrlResolver',
- async: true,
- pipeline: null,
-
- handle: function (item, callback) {
- var url = item.url;
- if (typeof url === 'string' && url.startsWith(RESOURCES_PROTOCOL)) {
- url = url.slice(RESOURCES_PROTOCOL.length);
- var uuid = this.resources.getUuid(url);
- if ( !uuid ) {
- var extname = cc.path.extname(url);
- if (extname) {
- //cc.warn('Don\'t add extension for "%s".', item.url);
- // strip extname
- url = url.slice(0, - extname.length);
- uuid = this.resources.getUuid(url);
- }
- }
- if (Array.isArray(uuid)) {
- cc.info('Wildcard NYI');
- if (uuid.length > 0) {
- uuid = uuid[0];
- }
- else {
- cc.info('TODO');
- }
- }
- if (uuid) {
- // load by uuid
- var pipeline = this.pipeline;
- pipeline.flowInDeps(
- [{
- id: uuid,
- type: 'uuid',
- uuid: uuid
- }],
- function (items) {
- var loaded = items[uuid];
- if (loaded) {
- item.content = loaded.content;
- pipeline.flowOut(item);
-
- // skip other pipes
- callback = null;
- }
- else {
- callback(new Error('TODO - what\'s wrong?'), null);
- }
- }
- );
- }
- else {
- callback(new Error('Resources path "' + item.url + '" does not exist.'));
- }
- }
- else {
- callback(null);
- }
- },
-
- resources: new AssetTable(),
-
- // resolve raw url for JSB
- getRawUrl: CC_JSB && function (url) {
- if (typeof url === 'string' && url.startsWith(RESOURCES_PROTOCOL)) {
- return cc.url.raw(url);
- }
- return url;
- }
-};
diff --git a/cocos2d/core/platform/CCAssetLibrary.js b/cocos2d/core/platform/CCAssetLibrary.js
index c150ec011d..1379ea5e45 100644
--- a/cocos2d/core/platform/CCAssetLibrary.js
+++ b/cocos2d/core/platform/CCAssetLibrary.js
@@ -26,7 +26,6 @@
var Asset = require('../assets/CCAsset');
var callInNextTick = require('./utils').callInNextTick;
var Loader = require('../load-pipeline/CCLoader');
-var resources = require('../load-pipeline/url-resolver').resources;
/**
* The asset library which managing loading/unloading assets in project.
@@ -319,7 +318,7 @@ var AssetLibrary = {
url = url.slice(RES_DIR.length);
}
// register
- resources.add(url, uuid);
+ Loader._resources.add(url, uuid);
}
}
}
diff --git a/cocos2d/core/platform/js.js b/cocos2d/core/platform/js.js
index f926c0500f..fa7dd3418e 100644
--- a/cocos2d/core/platform/js.js
+++ b/cocos2d/core/platform/js.js
@@ -166,7 +166,7 @@ var js = {
/**
* Derive the class from the supplied base class.
* Both classes are just native javascript constructors, not created by cc.Class, so
- * usually you will want to inherit using {% crosslink cc.Class cc.Class %} instead.
+ * usually you will want to inherit using {{#crossLink "cc/Class:method"}}cc.Class {{/crossLink}} instead.
*
* @method extend
* @param {Function} cls
diff --git a/cocos2d/core/platform/url.js b/cocos2d/core/platform/url.js
index 9a97443073..b23432da8f 100644
--- a/cocos2d/core/platform/url.js
+++ b/cocos2d/core/platform/url.js
@@ -47,9 +47,20 @@ cc.url = {
* @readOnly
*/
_builtinRawAssets: '',
+
+ normalize: function (url) {
+ if (url[0] === '.' && url[1] === '/') {
+ url = url.slice(2);
+ }
+ else if (url[0] === '/') {
+ url = url.slice(1);
+ }
+ return url;
+ },
/**
- * Returns the url of raw assets.
+ * Returns the url of raw assets, you will only need this if the raw asset is inside the "resources" folder.
+ *
* @method raw
* @param {String} url
* @return {String}
@@ -61,19 +72,9 @@ cc.url = {
return '';
}
- // normalize
- if (url[0] === '.' && url[1] === '/') {
- url = url.slice(2);
- }
- else if (url[0] === '/') {
- url = url.slice(1);
- }
+ url = this.normalize(url);
- var PROTO = 'resources://';
- if (url.startsWith(PROTO)) {
- url = 'resources/' + url.slice(PROTO.length);
- }
- else if ( !url.startsWith('resources/') ) {
+ if ( !url.startsWith('resources/') ) {
if (CC_EDITOR) {
cc.error('Should not load "%s" from script dynamically, ' +
'unless it is placed in the "resources" folder.', url);
@@ -93,20 +94,12 @@ cc.url = {
* @return {String}
* @example {@link utils/api/engine/docs/cocos2d/core/platform/url/builtinRaw.js}
*/
- builtinRaw: CC_EDITOR && function (url) {0
+ builtinRaw: CC_EDITOR && function (url) {
if ( !this._builtinRawAssets ) {
cc.error('Failed to init builtin asset\'s raw path.');
return '';
}
-
- // normalize
- if (url[0] === '.' && url[1] === '/') {
- url = url.slice(2);
- }
- else if (url[0] === '/') {
- url = url.slice(1);
- }
-
+ url = this.normalize(url);
return this._builtinRawAssets + url;
},
diff --git a/cocos2d/core/sprites/CCAnimationCache.js b/cocos2d/core/sprites/CCAnimationCache.js
index 7297f19402..1cc5074630 100644
--- a/cocos2d/core/sprites/CCAnimationCache.js
+++ b/cocos2d/core/sprites/CCAnimationCache.js
@@ -29,11 +29,10 @@
* cc.spriteFrameAnimationCache is a singleton object that manages the Animations.
* It saves in a cache the animations. You should use this class if you want to save your animations in a cache.
*
- * example
- * cc.spriteFrameAnimationCache.addAnimation(animation,"animation1");
- *
* @class
* @name cc.spriteFrameAnimationCache
+ * @example
+ * cc.spriteFrameAnimationCache.addAnimation(animation,"animation1");
*/
cc.spriteFrameAnimationCache = {
_animations: {},
diff --git a/cocos2d/core/utils/base-node.js b/cocos2d/core/utils/base-node.js
index 60e27474a2..271a2c031f 100644
--- a/cocos2d/core/utils/base-node.js
+++ b/cocos2d/core/utils/base-node.js
@@ -1493,7 +1493,7 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
var sibling = siblings[i];
sibling._sgNode.arrivalOrder = i;
}
- if (cc.renderer) {
+ if ( !CC_JSB ) {
cc.renderer.childrenOrderDirty = this._parent._sgNode._reorderChildDirty = true;
}
this._parent.emit(CHILD_REORDER);
diff --git a/cocos2d/core/utils/scene-graph-helper.js b/cocos2d/core/utils/scene-graph-helper.js
index 68fc30e985..5b6d2ffcb7 100644
--- a/cocos2d/core/utils/scene-graph-helper.js
+++ b/cocos2d/core/utils/scene-graph-helper.js
@@ -29,10 +29,11 @@ var SceneGraphUtils = {
removeSgNode: function () {
var node = this._sgNode;
if (node) {
- node.release();
- if (node._parent) {
- node._parent.removeChild(node);
+ var parent = node._parent;
+ if (parent) {
+ parent.removeChild(node);
}
+ node.release();
}
},
};
diff --git a/cocos2d/core/value-types/CCColor.js b/cocos2d/core/value-types/CCColor.js
index 4a94159a3b..686c7fb6ff 100644
--- a/cocos2d/core/value-types/CCColor.js
+++ b/cocos2d/core/value-types/CCColor.js
@@ -33,15 +33,18 @@ var Color = (function () {
*
* Each color component is a floating point value with a range from 0 to 255.
*
- * You can also use the convenience method <% crosslink cc.Color cc.Color %> to create a new Color.
+ * You can also use the convenience method {{#crossLink "cc/color:method"}}cc.color{{/crossLink}} to create a new Color.
*
* @class Color
* @extends ValueType
- * @constructor
+ */
+ /**
+ * @method Color
* @param {Number} [r=0] - red component of the color, default value is 0.
* @param {Number} [g=0] - green component of the color, defualt value is 0.
* @param {Number} [b=0] - blue component of the color, default value is 0.
* @param {Number} [a=255] - alpha component of the color, default value is 255.
+ * @return {Color}
*/
function Color( r, g, b, a ) {
if (typeof r === 'object') {
@@ -449,7 +452,11 @@ Color.hsv2rgb = function ( h, s, v ) {
cc.Color = Color;
/**
- * The convenience method to create a new <% crosslink cc.Color color %>
+ * @module cc
+ */
+
+/**
+ * The convenience method to create a new {{#crossLink "Color/Color:method"}}cc.Color{{/crossLink}}
* Alpha channel is optional. Default value is 255.
* @method color
* @param {Number} [r=0]
@@ -458,7 +465,7 @@ cc.Color = Color;
* @param {Number} [a=255]
* @return {Color}
*
- * @examples {@link utils/api/engine/docs/cocos2d/core/value-types/CCColor/color.js}
+ * @example {@link utils/api/engine/docs/cocos2d/core/value-types/CCColor/color.js}
*/
cc.color = function color (r, g, b, a) {
if (JS.isString(r)) {
diff --git a/cocos2d/core/value-types/CCRect.js b/cocos2d/core/value-types/CCRect.js
index 3ea8644405..5bdba66970 100644
--- a/cocos2d/core/value-types/CCRect.js
+++ b/cocos2d/core/value-types/CCRect.js
@@ -29,15 +29,18 @@ var JS = require('../platform/js');
/**
* A 2D rectangle defined by x, y position and width, height.
*
- * see {% crosslink cc.Rect cc.rect %}
- *
* @class Rect
* @extends ValueType
- * @constructor
+ */
+/**
+ * Constructor of cc.Rect class.
+ * see {{#crossLink "cc/rect:method"}} cc.rect {{/crossLink}} for convenience method.
+ * @method Rect
* @param {Number} [x=0]
* @param {Number} [y=0]
* @param {Number} [w=0]
* @param {Number} [h=0]
+ * @return {Rect}
*/
function Rect (x, y, w, h) {
if (x && typeof x === 'object') {
@@ -256,10 +259,13 @@ proto.containsRect = function (rect) {
cc.Rect = Rect;
-
+/**
+ * @module cc
+ */
/**
* The convenience method to create a new Rect.
+ * see {{#crossLink "Rect/Rect:method"}}cc.Rect{{/crossLink}}
* @method rect
* @param {Number[]|Number} [x=0]
* @param {Number} [y=0]
diff --git a/cocos2d/core/value-types/CCVec2.js b/cocos2d/core/value-types/CCVec2.js
index 175d650121..a6cc5ad046 100644
--- a/cocos2d/core/value-types/CCVec2.js
+++ b/cocos2d/core/value-types/CCVec2.js
@@ -37,9 +37,11 @@ var FireClass = require('../platform/CCClass');
/**
* Constructor
+ * see {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} or {{#crossLink "cc/p:method"}}cc.p{{/crossLink}}
* @method Vec2
* @param {number} [x=0]
* @param {number} [y=0]
+ * @return {Vec2}
*/
function Vec2 (x, y) {
if (x && typeof x === 'object') {
diff --git a/docs/cocos2d/core/animation-clip/curve-data.js b/docs/cocos2d/core/animation-clip/curve-data.js
new file mode 100644
index 0000000000..5ad9672332
--- /dev/null
+++ b/docs/cocos2d/core/animation-clip/curve-data.js
@@ -0,0 +1,58 @@
+{
+ // 根节点不用查找路径
+ // root properties
+ props: {
+ x: [
+ { frame: 0, value: 0, curve: [0,0.5,0.5,1] },
+ { frame: 1, value: 200, curve: null }
+ ]
+ },
+ comps: {
+ // component
+ 'comp-1': {
+ // component properties
+ 'prop-1': [
+ { frame: 0, value: 10, curve: [0,0.5,0.5,1] },
+ { frame: 1, value: 20, curve: null }
+ ]
+ }
+ },
+ paths: {
+ // key 为节点到root的路径名, 通过cc.find找到
+ 'foo/bar': {
+ // node properties
+ props: {
+ x: [
+ { frame: 0, value: 0, curve: [0,0.5,0.5,1]
+ { frame: 1, value: 200, curve: null }
+ ]
+ },
+ comps: {
+ // component
+ 'comp-1': {
+ // component property
+ 'prop-1': [
+ { frame: 0, value: 10, curve: [0,0.5,0.
+ { frame: 1, value: 20, curve: null }
+ ]
+ }
+ }
+ },
+ 'hello': {
+ props: {
+ position: [
+ {
+ frame: 0,
+ value: [0,0],
+ motionPath: [
+ [320, 240, 0, 240, 640, 240],
+ [640, 0, 400, 0, 1000, 0]
+ ]
+ },
+ { frame: 5, value: [640, 480] }
+ ]
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/docs/cocos2d/core/animation-clip/event-data.js b/docs/cocos2d/core/animation-clip/event-data.js
new file mode 100644
index 0000000000..d49fabd517
--- /dev/null
+++ b/docs/cocos2d/core/animation-clip/event-data.js
@@ -0,0 +1,8 @@
+[
+ frame: 0, func: 'onAnimationEvent1', params:['param-1', 'param-2']
+ frame: 2, func: 'onAnimationEvent3', params:['param-1', 'param-2']
+ frame: 3, func: 'onAnimationEvent2', params:['param-1']
+ // The second event at frame 3
+ frame: 3, func: 'onAnimationEvent4', params:['param-1']
+ frame: 4, func: 'onAnimationEvent4', params:['param-1']
+]
\ No newline at end of file
diff --git a/docs/cocos2d/core/event-manager/CCEventListener/create.js b/docs/cocos2d/core/event-manager/CCEventListener/create.js
index 534b300c52..39d7a99547 100644
--- a/docs/cocos2d/core/event-manager/CCEventListener/create.js
+++ b/docs/cocos2d/core/event-manager/CCEventListener/create.js
@@ -1,10 +1,18 @@
---------
+// Create KEYBOARD EventListener.
cc.EventListener.create({
+ event: cc.EventListener.KEYBOARD,
+ onKeyPressed: function (keyCode, event) {
+ cc.log('pressed key: ' + keyCode);
+ },
+ onKeyReleased: function (keyCode, event) {
+ cc.log('released key: ' + keyCode);
+ }
+});
- event: cc.EventListener.TOUCH_ONE_BY_ONE,
- swallowTouches: true,
- onTouchBegan: function (touch, event) {
- //do something
- return true;
- }
- });
+// Create ACCELERATION EventListener.
+cc.EventListener.create({
+ event: cc.EventListener.ACCELERATION,
+ callback: function (acc, event) {
+ cc.log('acc: ' + keyCode);
+ }
+});
\ No newline at end of file
diff --git a/docs/cocos2d/core/event-manager/CCEventManager/addListener.js b/docs/cocos2d/core/event-manager/CCEventManager/addListener.js
new file mode 100644
index 0000000000..13e955a2be
--- /dev/null
+++ b/docs/cocos2d/core/event-manager/CCEventManager/addListener.js
@@ -0,0 +1,20 @@
+// Add KEYBOARD EventListener To StatusLabel.
+cc.eventManager.addListener({
+ event: cc.EventListener.KEYBOARD,
+ onKeyPressed: function(keyCode, event){
+ var label = event.getCurrentTarget();
+ label.setString("Key " + keyCode.toString() + " was pressed!");
+ },
+ onKeyReleased: function(keyCode, event){
+ var label = event.getCurrentTarget();
+ label.setString("Key " + keyCode.toString() + " was released!");
+ }
+}, statusLabel);
+
+// Create ACCELERATION EventListener To Sprite.
+cc.eventManager.addListener({
+ event: cc.EventListener.ACCELERATION,
+ callback: function(acc, event){
+ //Here processing logic.
+ }
+}, sprite);
\ No newline at end of file
diff --git a/docs/cocos2d/core/event-manager/CCEventManager/removeListener.js b/docs/cocos2d/core/event-manager/CCEventManager/removeListener.js
new file mode 100644
index 0000000000..3aa76bde05
--- /dev/null
+++ b/docs/cocos2d/core/event-manager/CCEventManager/removeListener.js
@@ -0,0 +1,22 @@
+
+// 1. remove eventManager add Listener;
+var mouseListener1 = cc.eventManager.addListener({
+ event: cc.EventListener.MOUSE,
+ onMouseDown: function(keyCode, event){ },
+ onMouseUp: function(keyCode, event){ },
+ onMouseMove: function () { },
+ onMouseScroll: function () { }
+}, node);
+
+cc.eventManager.removeListener(mouseListener1);
+
+// 2. remove eventListener create Listener;
+var mouseListener2 = cc.EventListener.create({
+ event: cc.EventListener.MOUSE,
+ onMouseDown: function(keyCode, event){ },
+ onMouseUp: function(keyCode, event){ },
+ onMouseMove: function () { },
+ onMouseScroll: function () { }
+});
+
+cc.eventManager.removeListener(mouseListener2);
diff --git a/extensions/spine/Skeleton.js b/extensions/spine/Skeleton.js
index a7854faf94..92835d2b0d 100644
--- a/extensions/spine/Skeleton.js
+++ b/extensions/spine/Skeleton.js
@@ -55,7 +55,7 @@ sp.Skeleton = cc.Class({
name: 'sp.Skeleton',
extends: cc._RendererUnderSG,
editor: CC_EDITOR && {
- menu: 'i18n:MAIN_MENU.component.others/Spine Skeleton',
+ menu: 'i18n:MAIN_MENU.component.renderers/Spine Skeleton',
help: 'app://docs/html/components/spine.html',
//playOnFocus: true
},
@@ -76,6 +76,7 @@ sp.Skeleton = cc.Class({
this.defaultAnimation = '';
this._refresh();
},
+ tooltip: 'i18n:COMPONENT.skeleton.skeleton_data'
},
///**
@@ -171,7 +172,8 @@ sp.Skeleton = cc.Class({
},
type: DefaultSkinsEnum,
visible: true,
- displayName: "Default Skin"
+ displayName: "Default Skin",
+ tooltip: 'i18n:COMPONENT.skeleton.default_skin'
},
// value of 0 represents no animation
@@ -212,7 +214,8 @@ sp.Skeleton = cc.Class({
},
type: DefaultAnimsEnum,
visible: true,
- displayName: 'Animation'
+ displayName: 'Animation',
+ tooltip: 'i18n:COMPONENT.skeleton.animation'
},
//// for inspector
@@ -233,7 +236,12 @@ sp.Skeleton = cc.Class({
* @property {boolean} loop
* @default true
*/
- loop: true,
+ loop: {
+ default: true,
+ type: Boolean,
+ tooltip: 'i18n:COMPONENT.skeleton.loop'
+ },
+
/**
* The time scale of this skeleton.
@@ -246,7 +254,8 @@ sp.Skeleton = cc.Class({
if (this._sgNode) {
this._sgNode.setTimeScale(this.timeScale);
}
- }
+ },
+ tooltip: 'i18n:COMPONENT.skeleton.time_scale'
},
/**
@@ -262,6 +271,7 @@ sp.Skeleton = cc.Class({
}
},
editorOnly: true,
+ tooltip: 'i18n:COMPONENT.skeleton.debug_slots'
},
/**
@@ -277,6 +287,7 @@ sp.Skeleton = cc.Class({
}
},
editorOnly: true,
+ tooltip: 'i18n:COMPONENT.skeleton.debug_bones'
}
},
@@ -296,7 +307,7 @@ sp.Skeleton = cc.Class({
cc.error('Can not render dynamic created SkeletonData');
return null;
}
- var jsonFile = cc.AssetLibrary.getImportedDir(uuid) + '/' + uuid + '.raw.json';
+ var jsonFile = this.skeletonData.rawUrl;
var atlasFile = this.skeletonData.atlasUrl;
if (atlasFile) {
if (typeof atlasFile !== 'string') {
diff --git a/extensions/spine/editor/spine-meta.js b/extensions/spine/editor/spine-meta.js
index d666d7b155..1f784581ca 100644
--- a/extensions/spine/editor/spine-meta.js
+++ b/extensions/spine/editor/spine-meta.js
@@ -76,6 +76,8 @@ class TextureParser {
unload () {}
}
+const RAW_SKELETON_FILE = 'raw-skeleton.json';
+
class SpineMeta extends CustomAssetMeta {
constructor (assetdb) {
super(assetdb);
@@ -94,7 +96,7 @@ class SpineMeta extends CustomAssetMeta {
//this.textures[0] = value;
}
- static version () { return '1.0.1'; }
+ static version () { return '1.0.2'; }
static defaultType () {
return 'spine';
}
@@ -127,9 +129,9 @@ class SpineMeta extends CustomAssetMeta {
dests () {
var res = super.dests();
// for JSB
- res.push(this._assetdb._uuidToImportPathNoExt(this.uuid) + '.raw.json');
+ res.push(Path.join(this._assetdb._uuidToImportPathNoExt(this.uuid), RAW_SKELETON_FILE));
if (this.atlas) {
- res.push(this._assetdb._uuidToImportPathNoExt(this.atlas) + '.atlas');
+ res.push(this._assetdb.uuidToFspath(this.atlas));
}
return res;
}
@@ -185,8 +187,9 @@ class SpineMeta extends CustomAssetMeta {
asset.atlasUrl = db.uuidToUrl(atlasUuid);
db.mkdirForAsset(this.uuid);
- var rawJsonPath = db._uuidToImportPathNoExt(this.uuid) + '.raw.json';
+ var rawJsonPath = Path.join(db._uuidToImportPathNoExt(this.uuid), RAW_SKELETON_FILE);
Fs.copySync(fspath, rawJsonPath);
+ asset._setRawFiles([RAW_SKELETON_FILE]);
this.atlas = atlasUuid; // save for dest()
diff --git a/extensions/spine/index.js b/extensions/spine/index.js
index c8da7c1536..aafb6c6800 100644
--- a/extensions/spine/index.js
+++ b/extensions/spine/index.js
@@ -58,23 +58,32 @@ sp.ATTACHMENT_TYPE = {
};
/**
- * The event type of spine skeleton animation.
+ * !#en The event type of spine skeleton animation.
+ * !#zh 骨骼动画事件类型。
* @enum AnimationEventType
*/
sp.AnimationEventType = cc.Enum({
/**
+ * !#en The play spine skeleton animation start type.
+ * !#zh 开始播放骨骼动画。
* @property {Number} START
*/
START: 0,
/**
+ * !#en The play spine skeleton animation finish type.
+ * !#zh 播放骨骼动画结束。
* @property {Number} END
*/
END: 1,
/**
+ * !#en The play spine skeleton animation complete type.
+ * !#zh 播放骨骼动画完成。
* @property {Number} COMPLETE
*/
COMPLETE: 2,
/**
+ * !#en The spine skeleton animation event type.
+ * !#zh 骨骼动画事件。
* @property {Number} EVENT
*/
EVENT: 3
diff --git a/jsb/jsb-action.js b/jsb/jsb-action.js
index de14281367..b37c620b31 100644
--- a/jsb/jsb-action.js
+++ b/jsb/jsb-action.js
@@ -107,7 +107,9 @@ for (var i = 0; i < actionArr.length; ++i) {
continue;
var proto = type.prototype;
setCtorReplacer(proto);
- setAliasReplacer(name, type);
+ if (name.indexOf('Ease') === -1) {
+ setAliasReplacer(name, type);
+ }
}
function setChainFuncReplacer (proto, name) {
diff --git a/jsb/jsb-director.js b/jsb/jsb-director.js
index 3b4abbe1ab..7ea41db90b 100644
--- a/jsb/jsb-director.js
+++ b/jsb/jsb-director.js
@@ -95,16 +95,15 @@ cc.js.mixin(cc.director, {
* @param {Function} [onLaunched] - The function invoked at the scene after launch.
*/
runSceneImmediate: function (scene, onBeforeLoadScene, onLaunched) {
- // detach persist nodes
var id, node, game = cc.game;
var persistNodes = game._persistRootNodes;
- // Run an Entity Scene
if (scene instanceof cc.Scene) {
// ensure scene initialized
scene._load();
}
+ // detach persist nodes
for (id in persistNodes) {
node = persistNodes[id];
game._ignoreRemovePersistNode = node;
@@ -117,6 +116,7 @@ cc.js.mixin(cc.director, {
if (cc.isValid(oldScene)) {
oldScene.destroy();
}
+
this._scene = null;
// purge destroyed nodes belongs to old scene
@@ -127,8 +127,9 @@ cc.js.mixin(cc.director, {
}
this.emit(cc.Director.EVENT_BEFORE_SCENE_LAUNCH, scene);
- // Run an Entity Scene
var sgScene = scene;
+
+ // Run an Entity Scene
if (scene instanceof cc.Scene) {
this._scene = scene;
sgScene = scene._sgNode;
@@ -173,14 +174,12 @@ cc.js.mixin(cc.director, {
*/
runScene: function (scene, onBeforeLoadScene, onLaunched) {
cc.assert(scene, cc._LogInfos.Director.pushScene);
-
- // Run an Entity Scene
if (scene instanceof cc.Scene) {
// ensure scene initialized
scene._load();
}
- // Delay to avoid issues like transition in event callback
+ // Delay run / replace scene to the end of the frame
this.once(cc.Director.EVENT_AFTER_DRAW, function () {
this.runSceneImmediate(scene, onBeforeLoadScene, onLaunched);
});
@@ -241,43 +240,6 @@ cc.js.mixin(cc.director, {
}
},
- // load raw assets
- _loadRawAssets: function (assetObjects, done) {
- var urls = assetObjects.map(function (asset) {
- return asset.url;
- });
-
- //var info = 'preload ' + urls;
- //console.time(info);
-
- // currently cocos jsb 3.3 not support preload too much assets
- // so we divide assets to 30 a group
- var index = 0;
- var count = 30;
- var total = urls.length;
-
- function preload () {
- if (index + count > total) {
- // the last time
- count = total - index;
- }
-
- var assets = urls.slice(index, count);
-
- index += count;
-
- if (index < total) {
- cc.loader.load(assets, preload);
- }
- else {
- //console.timeEnd(info);
- done();
- }
- }
-
- preload();
- },
-
/**
* Loads the scene by its uuid.
* @method _loadSceneByUuid
@@ -299,10 +261,9 @@ cc.js.mixin(cc.director, {
}
}
else {
- var uuid = sceneAsset._uuid;
scene = sceneAsset.scene;
if (scene instanceof cc.Scene) {
- scene._id = uuid;
+ scene._id = sceneAsset._uuid;
self.runScene(scene, onUnloaded, onLaunched);
}
else {
@@ -315,7 +276,7 @@ cc.js.mixin(cc.director, {
if (error && onLaunched) {
onLaunched(error);
}
- }, { recordAssets: true });
+ });
}
});
diff --git a/jsb/jsb-etc.js b/jsb/jsb-etc.js
index 6b1b770d16..35ca6d4a6f 100644
--- a/jsb/jsb-etc.js
+++ b/jsb/jsb-etc.js
@@ -84,8 +84,10 @@ cc.Scheduler.prototype.unschedule = function (callback, target) {
this._unschedule(target, callback);
};
-// Node arrivalOrder
-cc.defineGetterSetter(cc.Node.prototype, "arrivalOrder", cc.Node.prototype.getOrderOfArrival, cc.Node.prototype.setOrderOfArrival);
+// Node
+var nodeProto = cc.Node.prototype;
+cc.defineGetterSetter(nodeProto, "arrivalOrder", nodeProto.getOrderOfArrival, nodeProto.setOrderOfArrival);
+cc.defineGetterSetter(nodeProto, "_parent", nodeProto.getParent, nodeProto.setParent);
// TextureCache addImage
if (!cc.TextureCache.prototype._addImageAsync) {
@@ -108,7 +110,6 @@ cc.TextureCache.prototype.addImage = function(url, cb, target) {
return this.addImageAsync(url, cb, target);
}
else {
- url = cc.Pipeline.UrlResolver.getRawUrl(url);
if (cb) {
return this._addImage(url, cb);
}
@@ -118,6 +119,95 @@ cc.TextureCache.prototype.addImage = function(url, cb, target) {
}
};
+// cc.SpriteFrame
+cc.SpriteFrame.prototype._ctor = function (filename, rect, rotated, offset, originalSize) {
+ if (originalSize !== undefined) {
+ if(filename instanceof cc.Texture2D) {
+ this.initWithTexture(filename, rect, rotated, offset, originalSize);
+ }
+ else {
+ this.initWithTexture(filename, rect, rotated, offset, originalSize);
+ }
+ } else if (rect !== undefined) {
+ if(filename instanceof cc.Texture2D) {
+ this.initWithTexture(filename, rect);
+ }
+ else {
+ this.initWithTextureFilename(filename, rect);
+ }
+ } else if (filename instanceof cc.Texture2D) {
+ rect = cc.rect(0, 0, filename.getPixelWidth(), filename.getPixelHeight());
+ this.initWithTexture(filename, rect);
+ }
+};
+
+// setTimeout, setInterval, clearTimeout, clearInteval
+var _windowTimeIntervalId = 0;
+var _windowTimeFunHash = {};
+var WindowTimeFun = function (code) {
+ this._intervalId = _windowTimeIntervalId++;
+ this._code = code;
+};
+
+WindowTimeFun.prototype.fun = function () {
+ if (!this._code) return;
+ var code = this._code;
+ if (typeof code === 'string') {
+ Function(code)();
+ }
+ else if (typeof code === 'function') {
+ code.apply(null, this._args);
+ }
+};
+
+/**
+ * overwrite window's setTimeout
+ @param {String|Function} code
+ @param {number} delay
+ @return {number}
+ */
+window.setTimeout = function (code, delay) {
+ var target = new WindowTimeFun(code);
+ if (arguments.length > 2)
+ target._args = Array.prototype.slice.call(arguments, 2);
+ var original = target.fun;
+ target.fun = function () {
+ original.apply(this, arguments);
+ clearTimeout(target._intervalId);
+ };
+ cc.director.getScheduler()._schedule(target.fun, target, delay / 1000, 0, 0, false, target._intervalId+'');
+ _windowTimeFunHash[target._intervalId] = target;
+ return target._intervalId;
+};
+
+/**
+ * overwrite window's setInterval
+ @param {String|Function} code
+ @param {number} delay
+ @return {number}
+ */
+window.setInterval = function (code, delay) {
+ var target = new WindowTimeFun(code);
+ if (arguments.length > 2)
+ target._args = Array.prototype.slice.call(arguments, 2);
+ cc.director.getScheduler()._schedule(target.fun, target, delay / 1000, cc.REPEAT_FOREVER, 0, false, target._intervalId+'');
+ _windowTimeFunHash[target._intervalId] = target;
+ return target._intervalId;
+};
+
+/**
+ * overwrite window's clearInterval
+ @param {number} intervalId
+ */
+window.clearInterval = function (intervalId) {
+ var target = _windowTimeFunHash[intervalId];
+ if (target) {
+ cc.director.getScheduler()._unschedule(target._intervalId+'', target);
+ delete _windowTimeFunHash[intervalId];
+ }
+};
+window.clearTimeout = clearInterval;
+
// ccsg
window._ccsg = {
Node: cc.Node,
diff --git a/jsb/jsb-event.js b/jsb/jsb-event.js
index 17648293e5..95848b34e3 100644
--- a/jsb/jsb-event.js
+++ b/jsb/jsb-event.js
@@ -170,19 +170,33 @@ cc.eventManager.removeListeners = function (target, recursive) {
};
cc.eventManager._pauseTarget = cc.eventManager.pauseTarget;
cc.eventManager.pauseTarget = function (target, recursive) {
+ var sgTarget = target;
+ target._eventPaused = true;
if (target instanceof cc.Component) {
- target = target.node._sgNode;
+ sgTarget = target.node._sgNode;
}
else if (target instanceof cc.Node) {
- target = target._sgNode;
+ sgTarget = target._sgNode;
}
- else if (!(target instanceof _ccsg.Node)) {
+ else if (!(sgTarget instanceof _ccsg.Node)) {
return;
}
- this._pauseTarget(target, recursive || false);
+
+ if (sgTarget !== target && !sgTarget.isRunning()) {
+ var originOnEnter = sgTarget.onEnter;
+ sgTarget.onEnter = function () {
+ originOnEnter.call(this);
+ if (target._eventPaused) {
+ cc.eventManager._pauseTarget(this, recursive || false);
+ }
+ this.onEnter = originOnEnter;
+ };
+ }
+ this._pauseTarget(sgTarget, recursive || false);
};
cc.eventManager._resumeTarget = cc.eventManager.resumeTarget;
cc.eventManager.resumeTarget = function (target, recursive) {
+ target._eventPaused = false;
if (target instanceof cc.Component) {
target = target.node._sgNode;
}
diff --git a/jsb/jsb-label.js b/jsb/jsb-label.js
index 4369f282e5..9f0fc4ec26 100644
--- a/jsb/jsb-label.js
+++ b/jsb/jsb-label.js
@@ -121,11 +121,8 @@ jsbLabel.prototype.setContentSize = function (size, height) {
};
jsbLabel.prototype.setFontFileOrFamily = function (fontHandle) {
- fontHandle = cc.Pipeline.UrlResolver.getRawUrl(fontHandle);
-
fontHandle = fontHandle || '';
var extName = cc.path.extname(fontHandle);
-
//specify font family name directly
if (!extName) {
this._labelType = _ccsg.Label.Type.SystemFont;
@@ -143,6 +140,8 @@ jsbLabel.prototype.setFontFileOrFamily = function (fontHandle) {
this.setFontSize(this.getFontSize());
}
}
+ //FIXME: hack for bmfont crash. remove this line when it fixed in native
+ this.getContentSize();
};
cc.Label = function (string, fontHandle) {
@@ -178,7 +177,8 @@ cc.Label = function (string, fontHandle) {
};
cc.Label.Type = cc.Enum({
TTF: 0,
- BMFont: 1
+ BMFont: 1,
+ SystemFont: 2
});
cc.Label.Overflow = cc.Enum({
NONE: 0,
diff --git a/jsb/jsb-loader.js b/jsb/jsb-loader.js
index d4f17fce1d..f68037f04a 100644
--- a/jsb/jsb-loader.js
+++ b/jsb/jsb-loader.js
@@ -38,7 +38,6 @@ function downloadScript (item, callback) {
function downloadText (item, callback) {
var url = item.url;
- url = cc.Pipeline.UrlResolver.getRawUrl(url);
var result = jsb.fileUtils.getStringFromFile(url);
if (typeof result === 'string' && result) {
@@ -49,6 +48,10 @@ function downloadText (item, callback) {
}
}
+function downloadAudio (item, callback) {
+ callback(null, item.url);
+}
+
cc.loader.addDownloadHandlers({
// JS
'js' : downloadScript,
@@ -66,11 +69,11 @@ cc.loader.addDownloadHandlers({
'image' : empty,
// Audio
- 'mp3' : empty,
- 'ogg' : empty,
- 'wav' : empty,
- 'mp4' : empty,
- 'm4a' : empty,
+ 'mp3' : downloadAudio,
+ 'ogg' : downloadAudio,
+ 'wav' : downloadAudio,
+ 'mp4' : downloadAudio,
+ 'm4a' : downloadAudio,
// Txt
'txt' : downloadText,
@@ -102,7 +105,6 @@ cc.loader.addDownloadHandlers({
function loadImage (item, callback) {
var url = item.url;
- url = cc.Pipeline.UrlResolver.getRawUrl(url);
var cachedTex = cc.textureCache.getTextureForKey(url);
if (cachedTex) {
diff --git a/jsb/jsb-particle.js b/jsb/jsb-particle.js
index c9e82dcf12..ad8440628a 100644
--- a/jsb/jsb-particle.js
+++ b/jsb/jsb-particle.js
@@ -94,8 +94,3 @@ for (var mode = 0; mode < funcNames.length; mode++) {
}
}
-var initWithFile = proto.initWithFile;
-proto.initWithFile = function (url) {
- url = cc.Pipeline.UrlResolver.getRawUrl(url);
- initWithFile.call(this, url);
-};
diff --git a/jsb/jsb-tex-sprite-frame.js b/jsb/jsb-tex-sprite-frame.js
index de595c9025..df25442a13 100644
--- a/jsb/jsb-tex-sprite-frame.js
+++ b/jsb/jsb-tex-sprite-frame.js
@@ -142,7 +142,7 @@ cc.SpriteFrame.prototype._deserialize = function (data, handle) {
cc.SpriteFrame.prototype._checkRect = function (texture) {
var rect = this.getRect();
var maxX = rect.x, maxY = rect.y;
- if (this._rotated) {
+ if (this.isRotated()) {
maxX += rect.height;
maxY += rect.width;
}
@@ -166,17 +166,25 @@ cc.SpriteFrame.prototype.getTexture = function () {
cc.js.set(cc.SpriteFrame.prototype, '_textureFilenameSetter', function (url) {
this._textureFilename = url;
if (url) {
- // texture will be init in getTexture()
- var texture = this.getTexture();
- if (this.textureLoaded()) {
+ cc.textureCache.addImage(url, function (texture) {
+ if (this.getTexture() !== texture) {
+ this.setTexture(texture);
+ var w = texture.getPixelWidth(), h = texture.getPixelHeight();
+ if (this.getRect().width === 0) {
+ this.setRect(cc.rect(0, 0, w, h));
+ }
+ if (this.getOriginalSize().width === 0) {
+ this.setOriginalSize(cc.size(w, h));
+ }
+ if (this.getOffset().width === 0) {
+ this.setOffset(cc.v2(0, 0));
+ }
+
+ this._texture = texture;
+ }
this._checkRect(texture);
this.emit('load');
- }
- else {
- // register event in setTexture()
- this._texture = null;
- this.setTexture(texture);
- }
+ }, this);
}
});
diff --git a/test/qunit/unit/test-class.js b/test/qunit/unit/test-class.js
index c0563b4dcb..4bead6df1b 100644
--- a/test/qunit/unit/test-class.js
+++ b/test/qunit/unit/test-class.js
@@ -627,3 +627,64 @@ test('lazy instantiate properties', function () {
var dog = new Husky();
deepEqual(Husky.__props__, ['like', 'weight'], 'could get properties in the correct order after instantiating');
});
+
+test('simplified properties define', function () {
+ var Type = cc.Class({
+ properties: {
+ bool: true,
+ string: "hello",
+ number: 2,
+ obj: null,
+ vec2: cc.Vec2,
+ vec2Val: new cc.Vec2(1, 2),
+ node: cc.Node,
+ }
+ });
+
+ var obj = new Type();
+
+ strictEqual(cc.Class.attr(Type, 'vec2').type, 'Object', 'checking vec2 type');
+ strictEqual(cc.Class.attr(Type, 'vec2').ctor, cc.Vec2, 'checking vec2 ctor');
+ strictEqual(cc.Class.attr(Type, 'node').type, 'Object', 'checking node type');
+ strictEqual(cc.Class.attr(Type, 'node').ctor, cc.Node, 'checking node ctor');
+
+ strictEqual(obj.bool, true, 'checking bool');
+ strictEqual(obj.string, "hello", 'checking string');
+ strictEqual(obj.number, 2, 'checking number');
+ strictEqual(obj.obj, null, 'checking obj');
+ strictEqual(obj.vec2 instanceof cc.Vec2, true, 'checking vec2');
+ deepEqual(obj.vec2Val, new cc.Vec2(1, 2), 'checking vec2 value');
+ strictEqual(obj.node, null, 'checking node');
+
+ var ArrayType = cc.Class({
+ properties: {
+ empty: [],
+ bool: [cc.Boolean],
+ string: [cc.String],
+ float: [cc.Float],
+ int: [cc.Integer],
+ valueType: [cc.Vec2],
+ node: [cc.Node],
+ rawAsset: [cc.RawAsset],
+ asset: [cc.Asset],
+ }
+ });
+
+ var arrayObj = new ArrayType();
+
+ strictEqual(cc.Class.attr(ArrayType, 'bool').type, cc.Boolean, 'checking array of bool type');
+ strictEqual(cc.Class.attr(ArrayType, 'valueType').type, 'Object', 'checking array of vec2 type');
+ strictEqual(cc.Class.attr(ArrayType, 'valueType').ctor, cc.Vec2, 'checking array of vec2 ctor');
+ strictEqual(cc.Class.attr(ArrayType, 'node').type, 'Object', 'checking array of node type');
+ strictEqual(cc.Class.attr(ArrayType, 'node').ctor, cc.Node, 'checking array of node ctor');
+ strictEqual(cc.Class.attr(ArrayType, 'rawAsset').type, 'Object', 'checking array of raw asset type');
+ strictEqual(cc.Class.attr(ArrayType, 'rawAsset').ctor, cc.RawAsset, 'checking array of raw asset ctor');
+
+ deepEqual(arrayObj.empty, [], 'checking array of empty');
+ deepEqual(arrayObj.bool, [], 'checking array of bool');
+ deepEqual(arrayObj.string, [], 'checking array of string');
+ deepEqual(arrayObj.valueType, [], 'checking array of valueType');
+ deepEqual(arrayObj.node, [], 'checking array of node');
+ deepEqual(arrayObj.rawAsset, [], 'checking array of rawAsset');
+ deepEqual(arrayObj.asset, [], 'checking array of asset');
+});
diff --git a/test/qunit/unit/test-resources-loader.js b/test/qunit/unit/test-resources-loader.js
index 171b0ccfc5..93e4aa0547 100644
--- a/test/qunit/unit/test-resources-loader.js
+++ b/test/qunit/unit/test-resources-loader.js
@@ -14,15 +14,15 @@
});
}
});
-
+
asyncTest('load single', function () {
cc.loader.releaseAll();
- cc.loader.load('resources://grossini.png', function (err, texture) {
+ cc.loader.loadRes('grossini.png', function (err, texture) {
ok(texture instanceof cc.Texture2D, 'should be able to load texture without file extname');
clearTimeout(timeoutId);
start();
});
-
+
var timeoutId = setTimeout(function () {
ok(false, 'time out!');
start();
diff --git a/test/qunit/unit/test-serialize.js b/test/qunit/unit/test-serialize.js
index 4694d19200..de35ffec54 100644
--- a/test/qunit/unit/test-serialize.js
+++ b/test/qunit/unit/test-serialize.js
@@ -119,7 +119,6 @@
__type__: 'MyAsset',
_objFlags: 0,
_name: '',
- _rawFiles: null,
emptyArray: [],
array: [1, '2', {a:3}, [4, [5]], true],
string: 'unknown',