minigame-canvas-engine中Layout的updateViewPort函数坐标原点为屏幕左上角。
https://wechat-miniprogram.github.io/minigame-canvas-engine/api/api.html#updateviewport
而我看SubContextView中的_updateSubContextView计算y坐标时是以屏幕左下角为原点的,只要SubContextView所在节点Y坐标不是0,点击就会不准。
修改前的代码:
// update viewport in subContextView
const viewportRect = view.getViewportRect();
const box = contentTrans.getBoundingBoxToWorld();
const visibleSize = view.getVisibleSize();
const dpr = screenAdapter.devicePixelRatio;
// TODO: the visibleSize need to be the size of Canvas node where the content node is.
const x = (viewportRect.width * (box.x / visibleSize.width) + viewportRect.x) / dpr;
const y = (viewportRect.height * (box.y / visibleSize.height) + viewportRect.y) / dpr;
......
修改后的代码:
const y = (viewportRect.height * ((visibleSize.height - box.height - box.y) / visibleSize.height) + viewportRect.y) / dpr;
尝试修改之后点击正常了。