CocosCreator 源码cc.FadeIn详解

/* 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);

};

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值