向量线性插值
任意值缓动
cc.misc.lerp(now,target,“比例”);
pos.lerp(targetPos,“比例”)
//相机跟随缓动
lateUpdate() {
let targetPos = cc.v2();
targetPos.y = this.playerGroup.y + 400;
//相机有一个最大移动范围在范围内移动
if (this.playerGroup.x >= 0) {
targetPos.x = this.playerGroup.x / 375 * 128;
} else if (this.playerGroup.x < 0) {
targetPos.x = -this.playerGroup.x / 375 * -128;
};
this.mainCamera.position = this.mainCamera.position.lerp(targetPos, 0.1);
},