/* Fades In an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 0 to 255.<br/>
* The "reverse" of this action is FadeOut
* @class FadeIn
* @extends FadeTo
* @param {Number} duration duration in seconds
*/
/* 淡入淡出 在实现 cc.RGBAProtocol 协议的对象中。它将不透明度从 0 修改为 255。<br/>
* 此操作的“反向”操作是 FadeOut
* @class 淡入
* @extends FadeTo
* @param {Number} 持续时间 持续时间(以秒为单位)
*/
cc.FadeIn = cc.Class({
name: 'cc.FadeIn',
extends: cc.FadeTo,
/* 继承自cc.FadeTo */
/* 构造函数 初始化时间 */
ctor: function (duration) {
if (duration == null)
duration = 0;
/* 声明_reverseAction 反向的action为null */
this._reverseAction = null;
/* 调用父类方法,初始化时间和透明度参数255,0-255代表完全透明到完全不透明 */
this.initWithDuration(duration, 255);
},
/* 创建一个相反的效果 */
reverse: function () {
/* 创建一个fadeout的action */
var action = new cc.FadeOut();
/* 初始化时间参数 */
action.initWithDuration(this._duration, 0);
/* 对action进行赋值 */
this._cloneDecoration(action);
/* 把easelist里面的action 进行reverse */
this._reverseEaseList(action);
/* 返回当前的动作 */
return action;
},
/* 复制本action */
clone: function () {
/* 创建一个FadeIn action */
var action = new cc.FadeIn();
/* 对action进行赋值 */
this._cloneDecoration(action);
/* 初始化时间参数 和透明度参数 */
action.initWithDuration(this._duration, this._toOpacity);
return action;
},
/* 传入target参数 */
startWithTarget: function (target) {
if (this._reverseAction)
this._toOpacity = this._reverseAction._fromOpacity;
/* 调用cc.FadeTo的 startWithTarget函数,传入target*/
cc.FadeTo.prototype.startWithTarget.call(this, target);
}
});
/**
* !#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}
* @example
* //example
* var action = cc.fadeIn(1.0);
*/
/* 创建fadeIn对象 */
cc.fadeIn = function (duration) {
return new cc.FadeIn(duration);
};
11-23
3863
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)