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类 ...
随机推荐
- BZOJ_4800_[Ceoi2015]Ice Hockey World Championship_双指针
BZOJ_4800_[Ceoi2015]Ice Hockey World Championship_双指针 Description 有n个物品,m块钱,给定每个物品的价格,求买物品的方案数. Inpu ...
- python 两个文件夹里的文件名对比
比如需要一个xml对应一个jpg时,有时候会不小心少了其中一个文件,这时可以用以下代码比较缺少的是哪个文件: # -*- coding: utf-8 -*- import os path1 = r'. ...
- LED全彩显示屏色度空间
摘要:LED全彩显示屏.LED电子大屏幕如果要有一个良好的视觉效果,其中色度占有一席重要的位置,那么该如何让LED显示屏的色度更均匀.合理呢,下面为大家总结出以下几点,供大家参考. LED全彩显示屏. ...
- Commons-FileUpload 常用API
ServerFileUpload类的常用方法 方法名称 方法描述 public void setSizeMax(long sizeMax) 设置请求信息实体内容的最大允许的字节数 public Lis ...
- bzoj 1652: [Usaco2006 Feb]Treats for the Cows【区间dp】
裸的区间dp,设f[i][j]为区间(i,j)的答案,转移是f[i][j]=max(f[i+1][j]+a[i](n-j+i),f[i][j-1]+a[j]*(n-j+i)); #include< ...
- bzoj 1753: [Usaco2005 qua]Who's in the Middle【排序】
--这可能是早年Pascal盛行的时候考排序的吧居然还是Glod-- #include<iostream> #include<cstdio> #include<algor ...
- P2252 取石子游戏
传送门 威佐夫博弈结论:若石子数为\(a,b(a<b)\),当且仅当\((y-x)*\frac{(\sqrt{5}+1)}{2}=x\)的时候先手必败 证明 //minamoto #includ ...
- P4110 [HEOI2015]小L的白日梦
传送门 题解 //minamoto #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef l ...
- SSH协议、HTTPS中SSL协议的完整交互过程
1.(SSH)公私钥认证原理 服务器建立公钥:每一次启动sshd服务时,该服务会主动去找/etc/ssh/ssh_host*的文件 客户端通过ssh工具进行连接,如Xshell,SecureCRT 服 ...
- spring data elasticsearch的 @Documnet 和 @Field 注解
@Documnet 注解 public @interface Document { String indexName(); //索引库的名称,个人建议以项目的名称命名 String type() de ...