setAnchorPoint 根本不生效, 虽然 anchorX 和 anchorY 变化了, 播放 scaleTo动画没有效果

setAnchorPoint 根本不生效, 虽然 anchorX 和 anchorY 变化了, 播放 scaleTo动画没有效果, 设置坐标也没有受到影响!!!

1赞

发现是 子节点没有跟随改变, 如果想整体设置锚点且位置不变 可以像这样
function setAnchorPointStay(node, anchorX, anchorY) {
let dx = (anchorX - node.anchorX) * node.width;
let dy = (anchorY - node.anchorY) * node.height;
node.x += dx;
node.y += dy;
node.children.forEach(child => {
child.x -= dx;
child.y -= dy;
});
node.setAnchorPoint(cc.p(anchorX, anchorY));
}

1赞