Cocos Creator 系统学习笔记(五)--action的使用

匿名 (未验证) 提交于 2019-12-02 22:56:40
cc.Class({     extends: cc.Component,      properties: {         // foo: {         //    default: null,      // The default value will be used only when the component attaching         //                           to a node for the first time         //    url: cc.Texture2D,  // optional, default is typeof default         //    serializable: true, // optional, default is true         //    visible: true,      // optional, default is true         //    displayName: 'Foo', // optional         //    readonly: false,    // optional, default is false         // },         // ...     },  /**Action   * 1: Action类是动作命令,我们创建Action,然后节点运行action就能够执行Action的动作;     2: Action分为两类: (1) 瞬时就完成的ActionInstant, (2) 要一段时间后才能完成ActionIntervial;     3: cc.Node runAction: 节点运行action;     4: cc.moveTo, cc.moveBy  To: 目标 By: 变化     5: cc.roateBy, cc.rotateTo,     6: cc.scaleBy, cc.scaleTo,     7: cc.fadeOut(淡出), cc.fadeIn(淡入):  cc.fadeTo();     8: cc.callFunc, cc.delayTime     9: cc.sequnce, cc.repeat, cc.repeatForever      10: Action easing(缓动的方式):  加上缓动特效, cc.easeXXXXX查看文档设置自己想要的缓动对象     11: stopAction: 停止运行action     12: stopAllActions: 停止所有的action;     */     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.runAction(sto);          // this.node.scale = 2;         // var sby = cc.scaleBy(1, 1.1); // 原来的基础,变化1.1 * 2         // this.node.runAction(sby);          // opactify         // var fin = cc.fadeIn(1);//1s         // 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 ####");*/          // 移动到 目的地,后,隐藏这个物体怎办? // 命令清单, [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);         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);          //停止指定动作         // this.node.stopAction(rf);         //停止所有的action         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);     },  });

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!