1: Action类是动作命令,我们创建Action,然后节点运行action就能够执行Action的动作;
2: Action分为两类: (1) 瞬时就完成的ActionInstant, (2) 要一段时间后才能完成ActionIntervial;
3: cc.Node runAction: 节点运行action;
4: cc.moveTo, cc.moveBy To: 目标 By: 变化
//Move
//将当前的节点移动到100,100的位置
var move1 = cc.moveTo(1,cc.Vec2.ONE.mul(100));
this.node.runAction(move1);
//将当前的节点早x和y的方向上各移动100
var move2 = cc.moveBy(1,cc.Vec2.ONE.mul(100));
this.node.runAction(move2);
5: cc.roateBy, cc.rotateTo,
//rotate
//1秒内循环到180度
var rotate1 = cc.rotateTo(1,180);
this.node.runAction(rotate1);
//1秒内将物体旋转增加180度
var rotate2 = cc.rotateBy(1,180);
this.node.runAction(rotate2);
6: cc.scaleBy, cc.scaleTo,
//scale
//从当前的缩放值变化到指定的缩放值
this.node.scale = 2;
// 缩放2到1.5
var scale1 = cc.scaleTo(1,1.5);
this.node.runAction(scale1);
//在原来的缩放比例上扩大指定的比例
//原来的缩放比例乘上执行的比例
this.node.scale = 1;
var scale2 = cc.scaleBy(1,2);
this.node.runAction(scale2);
7: cc.fadeOut(淡出), cc.fadeIn(淡入): cc.fadeTo();
//opactify
//淡入进来
var fin= cc.fadeIn(1)
this.node.opacity = 0;
this.node.runAction(fin);
//淡出 透明度为0 但是物体存在
var fout = cc.fadeOut(1);
this.node.runAction(fout);
//将透明度设置到指定的透明度上
var fto = cc.fadeTo(1,128);
this.node.runAction(fto);
8: cc.callFunc, cc.delayTime
// function Action
var func =cc.callFunc(()=>{
console.log("call func");
},this);
this.node.runAction(func);
时间延迟
var d1 = cc.delayTime(3);
var fout = cc.fadeOut(1);
var endfunc = cc.callFunc(()=>{
this.node.removeFromParent();
},this);
var seq = cc.sequence([d1,fout,endfunc]);
this.node.runAction(seq);
9: cc.sequnce, cc.repeat, cc.repeatForever
//一个节点可以同事运行多个Action
var m1 = cc.moveTo(1,100,100);
var f1 = cc.fadeOut(1);
this.node.runAction(m1);
this.node.runAction(f1);
//命令清单 动作序列
var m1 = cc.moveTo(1,100,100);
var f1 = cc.fadeOut(2);
var seq = cc.sequence([m1,f1]);
this.node.runAction(seq);
10: Action easing(缓动的方式): 加上缓动特效, cc.easeXXXXX查看文档设置自己想要的缓动对象
//回弹效果
this.node.y =0;
var m = cc.moveTo(1,100,0).easing(cc.easeBackOut());
this.node.runAction(m);
11: stopAction: 停止运行action
12: stopAllActions: 停止所有的action;