-
Creator 版本:2.3.1 (cc.ENGINE_VERSION)
-
目标平台: Web
-
详细报错信息,包含调用堆栈:
动态创建的节点,停止上一次的动画,添加本次动画,加入场景,循环以上操作。节点通过prefab创建,prefab是一个mask节点下面一个精灵节点。
以下是动画函数,cake就是创建的节点(mask+sprite)
const moveLeft = cc.tween().to(t, {
position: cc.v2(this.min_x, y)
}).to(t, {
position: cc.v2(this.max_x, y)
})
const moveRight = cc.tween().to(t, {
position: cc.v2(this.max_x, y)
}).to(t, {
position: cc.v2(this.min_x, y)
})
if (this.direction === 0) {
// 向左
this.cakeMove = moveLeft.clone(cake).repeatForever().start()
} else {
// 向右
this.cakeMove = moveRight.clone(cake).repeatForever().start()
}
停止动画的操作
if (this.cakeMove) {
this.cakeMove.stop()
this.cakeMove = null
}
