twfont
module game {
/**
*Created by 渔歌烟火 on 2018/3/28.
* 字体缓动动画
*/
export class LabelEffect {
private static _instance:LabelEffect;
public static get instance():LabelEffect
{
if( null == LabelEffect._instance )
{
LabelEffect._instance = new LabelEffect();
}
return LabelEffect._instance;
}
/**
* @param target 显示对象
* @param options 例如{ time: 1500,initNum:100,num: 88888, regulator: 50 }
*/
public playEffect(target:any,options:any){
options = options || {};
if(options.initNum==options.num)return;
var time = options.time,//总时间--毫秒为单位
finalNum = options.num, //要显示的真实数值
regulator = options.regulator || 100, //调速器,改变regulator的数值可以调节数字改变的速度
step = (finalNum-options.initNum) / (time / regulator),/*每30ms增加的数值--*/
count = options.initNum, //计数器
initial = options.initNum;
var timer = setInterval(()=> {
count = count + step;
if(count >= finalNum&&options.initNum<finalNum) {
clearInterval(timer);
count = finalNum;
}
if(count <= finalNum&&options.initNum>finalNum) {
clearInterval(timer);
count = finalNum;
}
//t未发生改变的话就直接返回
var t = Math.floor(count);
if(t == initial) return;
initial = t;
target.text = initial+"";
}, 30);
}
}
}
调用:LabelEffect.instance.playEffect(target, { time: 1500, initNum: num, num: score, regulator: 50 })
twfont的更多相关文章
随机推荐
- Java jar包启动脚本
#!/bin/bash APP_HOME=/wdcloud/app/rps/rps-module-admin APP_JAR=rps-module-admin-*.jar APP_PIDS=$(ps ...
- WEB 性能测试用例设计以及总结
WEB 性能测试用例设计以及总结 WEB 性能测试用例设计模型是设计性能测试用例的一个框架,在实际项目中,需要对其进行适当的剪裁,从而确定性能测试用例的范围和类别.剪裁的依据是性能测试策略和测试范围, ...
- ftp配置详解
FTP配置文件位置/etc/vsftpd.conflisten=NO设置为YES时vsftpd以独立运行方式启动,设置为NO时以xinetd方式启动(xinetd是管理守护进程的,将服务集中管理,可以 ...
- IO模型介绍
先理解几个问题: (1)为什么读取文件的时候,需要用户进程通过系统调用内核完成(系统不能自己调用内核)什么是用户态和内核态?为什么要区分内核态和用户态呢? 在 CPU 的所有指令中,有些指令是非常危险 ...
- zoj 3601
链接 [https://vjudge.net/contest/293343#problem/B] 题意 就是n男m女.然后给出他们喜欢那些人 再给出q次询问 每次参加party的人 让你找出某个人满足 ...
- Linux操作系统文件查找
++++++++++++++++++++++++++++++++++++++++++++++++标题:Linux操作系统的文件或命令查找内容:命令查找(which和whereis).文件查找(loca ...
- omit 配合antd from使用 hoistStatics
import omit from 'omit.js'; // 作用: 从已经存在的对象中过滤特定属性 const formProps = omit(this.props, [ 'prefixCls', ...
- servlet(5) HttpSession
Servlet 提供的 HttpSession 接口,提供了一种跨多个页面请求或访问网站时识别用户以及存储有关用户信息的方式. Servlet 容器使用这个接口来创建一个 HTTP 客户端和 HTTP ...
- 高新兴 ME3630-W 4G 模块 Android 平台适配
2019-04-26 关键字:高新兴 ME3630-W 适配.rk3128 移植 4G 模块 本篇文章系笔者在移植 高新兴物联 ME3630-W 4G 模块到运行着 Android4.4 操作系统的 ...
- Python中的eval(),exec()以及其相关函数
1. eval函数 函数的作用: 计算指定表达式的值.也就是说它要执行的Python代码只能是单个运算表达式(注意eval不支持任意形式的赋值操作),而不能是复杂的代码逻辑,这一点和lambda表达式 ...