[LayaAir 1.0]想要找设置相对坐标后的view全局坐标,发现有问题,请教一下.
想试着找出红色框的全局坐标, 利用localToGlobal获取不到正确的全局坐标位置, 以下为代码:
var local_point = new Point(view.userPanel.x, view.userPanel.y);
var userPanel_stage_point = view.userPanel.parent.localToGlobal(local_point);
这里的view就是图中背景, 而userPanel就是图中红色框
而view在UI编辑器里,设置的也是相对另一个scene的相对坐标, 所以层级是以下这样的.
stage->scene->view->userPanel
scene 坐标设置为左上角相对于stage的全局坐标 x,y,
view 坐标设置为相对于scene的相对坐标, 即: left top right bottom centerX centerY
userPanel 坐标设置为相对于view的相对坐标, 即: left top right bottom centerX centerY
现在想要获取 userPanel 的stage 全局坐标, 请教一下, 怎么获取?
var local_point = new Point(view.userPanel.x, view.userPanel.y);
var userPanel_stage_point = view.userPanel.parent.localToGlobal(local_point);
这里的view就是图中背景, 而userPanel就是图中红色框
而view在UI编辑器里,设置的也是相对另一个scene的相对坐标, 所以层级是以下这样的.
stage->scene->view->userPanel
scene 坐标设置为左上角相对于stage的全局坐标 x,y,
view 坐标设置为相对于scene的相对坐标, 即: left top right bottom centerX centerY
userPanel 坐标设置为相对于view的相对坐标, 即: left top right bottom centerX centerY
现在想要获取 userPanel 的stage 全局坐标, 请教一下, 怎么获取?
没有找到相关结果
已邀请:
要回复问题请先登录
4 个回复
shiyang
赞同来自:
var userPanel_stage_point = userPanel.localToGlobal(local_point);
这样就能获取
年年有肝
赞同来自:
Giealxon
赞同来自:
Giealxon
赞同来自: