cc.Node—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;
var mto = cc.moveTo(1, cc.p(100, 100)); // cc.moveTo(1, x, y);
this.node.runAction(mto);
var mby = cc.moveBy(5, 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);
console.log('初始宽:%f,高:%f', this.node.width, this.node.height); //
// scale
this.node.scale = 3;
var sto = cc.scaleTo(1, 1.5); // 到1.1倍
this.node.runAction(sto);
console.log('scaleTo 1.5宽:%f,高:%f', this.node.width, this.node.height); // var sby = cc.scaleBy(1, 1.5); // 原来的基础,变化1.5 * node.scale
this.node.runAction(sby);
console.log('scaleBy 1.5宽:%f,高:%f', this.node.width, this.node.height); //
//this.node.setContentSize(); // opactify
console.log('渐显效果');
var fin = cc.fadeIn(5); //渐显效果,返回 ActionInterval,参数 持续时间/秒
this.node.opacity = 0.5;
this.node.runAction(fin);
console.log('渐隐效果');
var fout = cc.fadeOut(1); //渐隐效果,返回 ActionInterval,参数 持续时间/秒
this.node.runAction(fout); // 物体还是在的的
var fto = cc.fadeTo(1, 128); //修改透明度到指定值,返回 ActionInterval,参数 duration、opacity(0-255透明底)
this.node.runAction(fto); // function Action
var func = cc.callFunc(function() {
console.log("callFunc at here");
}.bind(this)); console.log("begin ####");
this.node.runAction(func);
console.log("end ####"); // 移动到 目的地,后,隐藏这个物体怎办? // 命令清单(按顺序执行action命令) [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();//停止所有Action
// 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);
cc.Node—Action的更多相关文章
- cc.Node 的坐标空间与ACTION的学习
1.创建二维的向量坐标 //创建向量坐标方法一 let new_pos1 = new cc.Vec2(100, 100); //创建向量坐标方法二 let new_pos2 = cc.v2(200, ...
- cc.Node—场景树
对于cc.Node我分了四个模块学习: 1.场景树,2.事件响应,3.坐标系统,4.Action的使用:在此记录经验分享给大家. 场景树 1: creator是由一个一个的游戏场景组成,通过代码逻辑来 ...
- Cocos Creator cc.Node.点击事件
触摸事件 1.触摸事件的类型:START触摸启动,MOVED移动,ENDED弹起来,CANCEL取消; ENDED和CANCEL区别是ENDED物体内弹起来,CANCEL是在物体外范围弹起. 2.监听 ...
- <7>Cocos Creator 节点 cc.Node
1.简介 节点(cc.Node)是渲染的必要组成部分.所有需要在游戏场景中显示的内容都必须是节点或者依附于节点之上.节点负责控制显示内容的位置.大小.旋转.缩放.颜色等信息. 2.节点属性 1: na ...
- cc.Node—坐标系统
cc.Vec21: cc.Vec2 二维向量坐标, 表结构{x: 120, y: 120}; cc.v2(x, y) 创建一个二维向量 cc.p() 创建一个二外向量;2: cc.pSub: 向量相减 ...
- cc.Node—事件响应
触摸事件1: 触摸事件类型: START, MOVED, ENDED(物体内), CANCEL(物体外);2: 监听触摸事件: node.on(类型, callback, target(回掉函数的th ...
- cc.Sprite
Classcc.Sprite Defined in: CCSprite.js Extends cc.NodeRGBA Class Summary Constructor Attributes Cons ...
- Cocos2d-JS中的cc.LabelAtlas
cc.LabelAtlas是图片集标签,其中的Atlas本意是“地图集”.“图片集”,这种标签显示的文字是从一个图片集中取出的,因此使用cc.LabelAtlas需要额外加载图片集文件.cc.Labe ...
- Cocos2d-JS中的cc.LabelTTF
cc.LabelTTF是使用系统中的字体,它是最简单的标签类.cc.LabelTTF类图如下图所示,可以cc.LabelTTF继承了cc.Node类,具有cc.Node的基本特性. LabelTTF类 ...
随机推荐
- easyUI 对话框的关闭事件
有一个easyUI的dialog: <div id="dlg_Add" class="easyui-dialog" style=" width: ...
- Interval 计时器
语法: setInterval(代码,交互时间); 在执行时,从载入页面后每隔指定的时间执行代码. clearInterval( setInterval() 返回的 ID 值 ): 取消计时器 < ...
- 安装linux系统-CentOS-6.8-x86_64-minimal.iso
1: 2: 3:单击[Next]继续安装. 4:安装语言,选择[Chinese(Simplified)(中文(简体))]菜单,单击[Next]继续. 5:系统键盘,选择[美国英语式]菜单,单击[下一步 ...
- bzoj1016 [JSOI2008]最小生成树计数——Kruskal+矩阵树定理
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1016 从 Kruskal 算法的过程来考虑产生多种方案的原因,就是边权相同的边有一样的功能, ...
- Java经典算法之折半查找(二分法)
采用二分法时,数据应是有序并且不重复的 与小时候玩的猜数游戏是一样的,会让你猜一个他所想的1~100之间的数,当你猜了一个数后,他会告诉你三种选择中的一个,比他想的大,或小,或猜中了,为了能用最少的次 ...
- O(1)的快速乘
那么 有位神仙已经说了O(1)的算法(当然不是我) 这是一种骚操作 直接放代码了啊 inline LL mul(LL a,LL b,LL Mod){ LL lf = a * ( b >> ...
- 洛谷P1010 幂次方
题目描述 任何一个正整数都可以用2的幂次方表示.例如 137=2^7+2^3+2^0 同时约定方次用括号来表示,即a^b 可表示为a(b). 由此可知,137137可表示为: 2(7)+2(3)+2( ...
- 关于ListView的注意点
解决ListView的一些常见问题: 1.listview在拖动的时候背景图片消失变成黑色背景,等到拖动完毕我们自己的背景图片才显示出来 解决:在XML中加入 android:scrollingCac ...
- [Qt Quick入门] 基本元素初体验
Qt Quick作为QML语言的标准库,提供了很多基本元素和控件来帮助我们构建Qt Quick应用.这节我们简要地介绍一些Qt Quick元素,如Rectangle.Item.Text.Button. ...
- 全面学习ORACLE Scheduler特性(1)创建jobs
所谓出于job而胜于job,说的就是Oracle 10g后的新特性Scheduler啦.在10g环境中,ORACLE建议使用Scheduler替换普通的job,来管理任务的执行.其实,将Schedul ...