首页 > 其他 > 详细

label动态加减变更效果

时间:2019-05-09 19:11:52      阅读:114      评论:0      收藏:0      [点我收藏+]
showPollMoney(num) {//默认状态,一般在onload()调用
this.poolMoney.string = num;//poolMoney是要动态显示的label,
var len = this.poolMoney.string.length
if (len < 14) {
var str = this.poolMoney.string
for (var i = 0; i < 14 - len; i++) {//默认14位0
str = "0" + str;
}
}
this.poolMoney.string = str;
},
//***每次改变值时调用,jackpot是传入的最终值
showJackpot(jackpot) {
var str_jackpot = this.poolMoney.string;
var cur_jackpot = parseInt(str_jackpot);
var interval =10;//根据效果调整累加值
this.jackpotAction = cc.repeatForever(cc.sequence(cc.delayTime(0.01), cc.callFunc(function () {
cur_jackpot = cur_jackpot + interval;
if (cur_jackpot > jackpot) {
cur_jackpot = jackpot;
this.poolMoney.node.stopAllActions();
}
var str = "";
for (var j = 0; j < 14 - ("" + cur_jackpot).length; ++j) {
str = str + "0";
}
this.poolMoney.string = str + cur_jackpot;
}.bind(this))));
this.poolMoney.node.runAction(this.jackpotAction);
},
//比如断线后设置原来的值时调用
setPoolMoney(money) {
var times = 20;
if (money > 10000) {
times = 50;
} else if ((money > 1000 && money <= 10000)) {
times = 30;
}
var num = parseInt(this.poolMoney.string);
var interval = parseInt(Math.floor(money) / Math.floor(times));
this.poolMoneyAction = cc.repeatForever(cc.sequence(cc.delayTime(0.01), cc.callFunc(function () {
num = num + interval;
if (num >= money) {
num = money
this.showPollMoney(num);
this.poolMoney.node.stopAllActions();
}
this.showPollMoney(num);
}.bind(this))));

this.poolMoney.node.runAction(this.poolMoneyAction);
},

 

label动态加减变更效果

原文:https://www.cnblogs.com/CC-Right/p/10839989.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!