action
2016-06-22 09:07
302 查看
cc.sequence 创建动作序列
cc.delaytime(2) 延时多少秒
cc.rotateto rotatebt 以锚点为中心旋转
Action对象是随着时间改变Node的属性。任何一个以Node为基类的对象都有可执行的动作对象。
例如,你可以在一个时间段内将Sprite精灵从一个位置移动到另一个位置。
如下为MoveTo和MoveBy两个动作的实例:
moveTo和 Moveby两个动作的实例:
//Move sprite to position 50,10 in 2 seconds
var moveTo =cc.move To ( 2,cc.p(50,10));
my Sprite1.runAction(moveTo);
//Move sprite 20 points to right in 2 seconds
var moveBy = cc.moveBy(2,cc.p(20,0));
mySprite1,runAction(moveBy);
By和To的区别:
By相对于节点是相对的
To相对于节点是绝对的
var mySprite = new cc.Sprite("mySprite.png");
mySprite.setPosition(200,256);
//MoveBy - lets move the sprite by 500 on the x axis over 2 seconds
//MoveBy is relative - since x = 200+200 move =x is now 400 after the move
var moveBy = cc.moveBy(2,cc.p(500, mySprite.y));
//MoveTo -lets move the new sprite to 300 x 256 over 2 seconds
// MoveTo is ab solute - The sprite gets moved to 300 x256 regardless of
// where it is located now.
var moveTo = cc.moveTo(2,cc.p(300,mySprite.y));
var delay = 2.0;
var seq =cc. sequence(moveBy,delay,moveTo);
mySprite.runAction(seq);
旋转 (Rotate)
var mySprite = new cc. sprite("mySprite.png");
var rotateTo =cc. rotateTo(2,40);
mySprite.runAction(moveTo);
var rotateBy = cc.rotateBy(2,40);
my Sprite. runAction(rotateBy);
缩放(Scale)
var mySprite =new cc.Sprite ("mySprite.png");
var scaleBy = cc.scaleBy(2.0,3.0);
mySprite.runAction(scaleBy);
var scaleBy =cc.scaleBy(2.0,3.0,3.0);
my Sprite.runAction(scaleBy);
cc.delaytime(2) 延时多少秒
cc.rotateto rotatebt 以锚点为中心旋转
Action对象是随着时间改变Node的属性。任何一个以Node为基类的对象都有可执行的动作对象。
例如,你可以在一个时间段内将Sprite精灵从一个位置移动到另一个位置。
如下为MoveTo和MoveBy两个动作的实例:
moveTo和 Moveby两个动作的实例:
//Move sprite to position 50,10 in 2 seconds
var moveTo =cc.move To ( 2,cc.p(50,10));
my Sprite1.runAction(moveTo);
//Move sprite 20 points to right in 2 seconds
var moveBy = cc.moveBy(2,cc.p(20,0));
mySprite1,runAction(moveBy);
By和To的区别:
By相对于节点是相对的
To相对于节点是绝对的
var mySprite = new cc.Sprite("mySprite.png");
mySprite.setPosition(200,256);
//MoveBy - lets move the sprite by 500 on the x axis over 2 seconds
//MoveBy is relative - since x = 200+200 move =x is now 400 after the move
var moveBy = cc.moveBy(2,cc.p(500, mySprite.y));
//MoveTo -lets move the new sprite to 300 x 256 over 2 seconds
// MoveTo is ab solute - The sprite gets moved to 300 x256 regardless of
// where it is located now.
var moveTo = cc.moveTo(2,cc.p(300,mySprite.y));
var delay = 2.0;
var seq =cc. sequence(moveBy,delay,moveTo);
mySprite.runAction(seq);
旋转 (Rotate)
var mySprite = new cc. sprite("mySprite.png");
var rotateTo =cc. rotateTo(2,40);
mySprite.runAction(moveTo);
var rotateBy = cc.rotateBy(2,40);
my Sprite. runAction(rotateBy);
缩放(Scale)
var mySprite =new cc.Sprite ("mySprite.png");
var scaleBy = cc.scaleBy(2.0,3.0);
mySprite.runAction(scaleBy);
var scaleBy =cc.scaleBy(2.0,3.0,3.0);
my Sprite.runAction(scaleBy);
相关文章推荐
- CocoPod 安装使用
- VII Python(6)基础知识(re正则表达式、MySQLdb模块)
- Android Studio开发NDK流程--经验
- How to integrate Identity System in Activiti
- oracle imp导入库到指定表空间
- 协方差矩阵的一些理解,转载
- LDPC 学习记录
- Nginx端口的修改
- Linux打印出netstat -anp 里的Send_Q发送堵的TCP连接
- 提高mysql千万级大数据SQL查询优化30条经验(Mysql索引优化注意)
- 6.22软件工程总结
- C# 中正则表达式 Group 分组【转】
- android面试日记--20160619
- java程序性能优化
- English - when用法
- 删除项目中的所有(.svn)文件 或(CVS)文件夹
- 动态规划-ZOJ 1 163 THE STAIRCASES
- Swing Jtable 设置背景色
- android inflater 用法
- 24种设计模式——代理模式