新学了一个优雅的tween改组件属性的代码

const bgProcess=this.bgProcessNode.getComponent(cc.ProgressBar)
    const _proxy = new Proxy({progress:Math.max(0,(cur-1)/all)}, {
        set(target, key, value) {
            if (key == 'progress') {
                bgProcess.progress =value
            }
            return true;
        }
    })
    cc.tween(_proxy).to(1,{progress:cur/all }).start()

以前这类改非node属性的代码都用schedule,没tween好用

2赞

可喜可贺~