cc.tween(this.node.getComponent(cc.Label))
.to(1, {string: "10"})
.start()
这样不行吧,会报错,,那有没有办法实现这个效果呢,用cc.tween
cc.tween(this.node.getComponent(cc.Label))
.to(1, {string: "10"})
.start()
这样不行吧,会报错,,那有没有办法实现这个效果呢,用cc.tween
Can not animate string property, because it do not have [lerp, (add|mul), clone] function.
就是说,字符串不能用cc.tween做动画吗
你骨骼真惊奇
let lbl = this.getComponentInChildren(cc.Label); var obj = { a: 0 } cc.tween(obj).to(1, { a: 100}, {progress:(s , e, c ,t)=>{ let num = Math.round(e * t); lbl.string = String(num); }}).start();
不知道为啥,current 是undefined
请问此处,progress这个函数具体是怎么用的
因为string类型不能进行算数运算,所以正确的做法就是使用数值变量进行运算,得到结果后转化为字符类型。
tween的效果就是在用计时器来不断改变某个值,progress就是计时器的回调函数,tween变化的属性值都会反应在progress函数中,所以在这个函数里来将数值类型转化为字符后赋予label的string。
其实按照你的需求,可能直接用schedule计时器更适合一些
https://docs.cocos.com/creator/manual/zh/scripting/tween.html?h=progress
不懂其实先去看文档,这种一般都有说明