function updateJumpNumber(newNum,oldNum)
-- 数字变化时间间隔
self.dt = 0.05
-- 数字变化次数
self.count = 40
local text = ccui.Text:create()
local number = newNum - oldNum
if math.abs(number) >= self.count then
-- 数字变化self.count次,num1为每次变化的幅度,num2为 number%self.count 的余数
local num1,num2 = math.modf(number/self.count)
-- print(string.format("*************1 num1 = %d, num2 = %d",num1,num2))
local num1 = num1
local num2 = num2*self.count
local number1 = oldNum
for j = 1, self.count do
text:runAction(cc.Sequence:create(cc.DelayTime:create(self.dt*(j-1)),cc.CallFunc:create(function(sender)
if j == self.count then
number1 = number1+num1+num2
else
number1 = number1+num1
end
sender:setString(number1)
self:adaptSize(sender)
end)))
end
else
text:setString(list2[i].gold)
self:adaptSize(text)
end
end
cocos2d-x lua 简单实现数字跳分效果
最新推荐文章于 2024-07-16 21:10:48 发布