将图像分成4个局部遮罩,但宽度不能为 在1/2之后显示 this.goodObjects 是要显示的图像数组 绿色袜子动画库中的TimelineMax
let len = this.goodObjects.length
let n = 4
this.goodObjects.forEach((object, i) => {
object.alpha = 0
if (i !== len - 1) {
let bound = this.goodObjects[i + 1].getBounds()
let w = bound.width
let h = bound.height
for (let j = 0; j < n; j++) {
let imgTween = new TimelineMax({ repeat: 1, repeatDelay: 1 })
const tween = new TweenLine()
let o = _.cloneDeep(this.goodObjects[i + 1])
o.cache((w * j) / n, 0, w / n, h)
o.filters = [
new createjs.AlphaMaskFilter(o.cacheCanvas),
]
let v = { w: (w * j) / n }
imgTween.add(tween.to(v, 0.5, {
w: (w * (j + 1)) / n,
ease: Power0.easeNone,
onUpdate: () => {
object.alpha = 1
o.cache((w * j) / n, 0, v.w, h)
// o.updateCache()
this.stage.addChild(o)
},
}))
}
}
})