微信小游戏-CocosCreator 基础(五)

Action:用来实现2d的动效

=========================
cc.Class({
    extends: cc.Component,

    properties: {
    
    },

   
    onLoad: function () {
        // move
        // var mto = cc.moveTo(1, cc.p(100, 100)); // cc.moveTo(1, x, y);
        // this.node.runAction(mto);
        // var mby = cc.moveBy(1, cc.p(100, 100)); // cc.moveBy(1, x, y); 变化多少
        // this.node.runAction(mby);

        // rotate
        // var rto = cc.rotateTo(1, 180);  // 旋转到180度; rotation 180;
        // this.node.runAction(rto);
        // var rby = cc.rotateBy(1, 75); // 在原来的基础上,变化75,可正,可负
        // this.node.runAction(rby); 

        // scale
        // this.node.scale = 2;
        // var sto = cc.scaleTo(1, 1.1); // 到1.1倍, this.node.scale = 1.1;
        // this.node.runAction(sto);

        // this.node.scale = 2;
        // var sby = cc.scaleBy(1, 1.1); // 原来的基础,变化this.node.scale=1.1 * 2
        // this.node.runAction(sby);

        // opactify
        // var fin = cc.fadeIn(1);
        // this.node.opacity = 0;
        // this.node.runAction(fin);
        // var fout = cc.fadeOut(1);
        // this.node.runAction(fout); // 物体还是在的的
        // var fto = cc.fadeTo(1, 128);//(时间,透明度)
        // this.node.runAction(fto);

        // function Action
        /*var func = cc.callFunc(function() {
            console.log("call Func actin!!!!!");
        }.bind(this));

        console.log("begin ####");
        this.node.runAction(func); 
        console.log("end ####");*/ //执行结果:begin end  call Func actin!!!!!

        // 移动到 目的地,后,隐藏这个物体怎办? // 命令清单, [Action1, A2, A3], 
        // seq Action 先后
        /*var m1 = cc.moveTo(1, 100, 100);
        var fout = cc.fadeOut(0.5);

        var seq = cc.sequence([m1, fout]);
        this.node.runAction(seq);*/

        // 一个节点可以同时运行多个Action, 一边,一边
        /*var m1 = cc.moveTo(1, 100, 100);
        var fout = cc.fadeOut(0.5);

        this.node.runAction(fout);
        this.node.runAction(m1);*/

        // 不断的放大缩小
        /*var s1 = cc.scaleTo(0.8, 1.1);
        var s2 = cc.scaleTo(0.8, 0.8);
        var seq = cc.sequence([s1, s2]);
        var rf = cc.repeatForever(seq);//反复循环,先返回s1
        this.node.runAction(rf);*/

        // 匀速的飞过,傻了, 缓动特效
        // 回弹
        /*this.node.y = 0;
        var m = cc.moveTo(1, 100, 0).easing(cc.easeBackOut());
        this.node.runAction(m);*/
        
        /*var r = cc.rotateBy(3, 360).easing(cc.easeCubicActionOut());
        var rf = cc.repeatForever(r);
        this.node.runAction(rf);

         //停止action
        // this.node.stopAction(rf);
        this.node.stopAllActions();*/
        // end 

        // 移动了到100, 0,删除
        /*var m = cc.moveTo(1, 100, 0);
        var end_func = cc.callFunc(function() {
            this.node.removeFromParent();
        }.bind(this));
        var seq = cc.sequence([m, end_func]);
        this.node.runAction(seq);*/

        // cc.Delay,
        var d1 = cc.delayTime(3);
        var fout = cc.fadeOut(0.5);
        var end_func = cc.callFunc(function() {
            this.node.removeFromParent();//从父节点中删除该节点。
        }.bind(this))

        var seq = cc.sequence([d1, fout, end_func]);
        this.node.runAction(seq);
    },

  
});
 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Cocos Creator是一款流行的游戏开发引擎,它提供了方便的工具和功能,可以帮助开发者在多个平台上创建游戏,包括微信小游戏平台。 接入微信小游戏的步骤如下: 1. 准备工作: - 确保你已经安装并配置好了Cocos Creator开发环境。 - 在微信公众平台上注册一个小程序账号,并获取到小程序的AppID。 2. 创建项目: - 打开Cocos Creator,选择新建项目,并选择微信小游戏项目模板。 - 配置项目信息,包括项目名称、路径等。 3. 项目设置: - 在项目设置中,选择微信小游戏平台,并填写小程序的AppID。 - 根据需要配置其他相关设置,如屏幕适配、引擎版本等。 4. 开发游戏: - 使用Cocos Creator提供的编辑器和工具进行游戏开发。 - 可以使用JavaScript或TypeScript编写代码,创建场景、精灵、动画等。 5. 调试与预览: - 在Cocos Creator中,可以选择微信小游戏平台进行调试和预览。 - 在微信开发者工具中,导入Cocos Creator生成的小游戏项目,并进行调试、预览和测试。 6. 发布与上线: - 在Cocos Creator中,选择发布小游戏,并按照提示进行配置和打包。 - 将生成的小游戏包上传至微信开放平台,并进行审核和发布。 以上是接入微信小游戏的基本步骤,具体的细节和操作步骤可以参考Cocos Creator的官方文档和微信小游戏的开发文档,以获得更详细的指导。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值