博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
cocos2d的常用动作及效果总结之三:Ease actions
阅读量:7040 次
发布时间:2019-06-28

本文共 861 字,大约阅读时间需要 2 分钟。

Ease actions 影响的是动作的时间线性。

举个例子,比如你想让一个精灵的运动由快到慢的变化;又或者一开始慢然后开始变快接着再慢下来,想像一下钟摆的运动。

用Ease actions就可以简单实现上面这种看似复杂的运动。

Ease actions 

包含 CCEaseIn,CCEaseOut,CCEaseInOut三个类,示例:

id action = [CCMoveTo actionWithDuration:2 position:ccp(100,100)];id ease = [CCEaseIn actionWithAction:action rate:2];[sprite runAction: ease]; 

actionwithaction参数就是要用Ease来处理的动作, rate是加速率,不过这个加速率具体什么数值合适可能要慢慢试一试了。上例就是sprite在一开始加速向移动到(100,100)位置。

其他两个使用的格式一样,只是效果不同,可以每个试试看看效果。

EaseSine actions

包含CCEaseSineIn, CCEaseSineOut,CCEaseSineInOut  三个类,示例:

// Sine at the beginningid move = [CCMoveBy actionWithDuration:3 position:ccp(350,0)];id action = [CCEaseSineIn actionWithAction:move];[sprite runAction:action];

这个与上面的 Ease actions部分不同的是加速率。

CCEaseSineOut,CCEaseSineInOut两个使用的方式和上面是一样的,只是时间变化有所不同。

其他的几种 ease actions 暂时还没用到,以后用到后会再补充。

转载于:https://www.cnblogs.com/pengyingh/articles/2433362.html

你可能感兴趣的文章
数据结构和算法 – 10.集合
查看>>
关于新版SDK报错You need to use a Theme.AppCompat theme的两种解决办法
查看>>
微信热门话题榜要上线了?腾讯微博的变身?
查看>>
Android 初阶自定义 View 字符头像
查看>>
Oracle Stream配置详细步骤
查看>>
设计模式学习笔记(十五:组合模式)
查看>>
继承与组合
查看>>
Spring 读取配置文件(一)
查看>>
转:JavaScript函数式编程(三)
查看>>
isnull的使用方法
查看>>
struts2和spring mvc的比较
查看>>
Apache shiro之权限校验流程
查看>>
变通实现微服务的per request以提高IO效率(二)
查看>>
css中px和em,rem
查看>>
TCP_Wrappers
查看>>
Go总结(2)
查看>>
Spring源码分析:BeanPostProcessor原理
查看>>
Kubernetes审计日志方案
查看>>
Dva.js总结
查看>>
将 vue 项目运行在 docker 的 nginx 容器中
查看>>