[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 全局坐标, 请教一下, 怎么获取?
31163bba118198c4458afb4cbd5c57d.png
已邀请:

shiyang

赞同来自:

var local_point = new Point();
var userPanel_stage_point = userPanel.localToGlobal(local_point);
 
这样就能获取

年年有肝

赞同来自:

var userPanel_stage_point = view.userPanel.localToGlobal(local_point); 试试

Giealxon

赞同来自:

你需要一層一層的找好像

Giealxon

赞同来自:

或者自己計算
 

要回复问题请先

商务合作
商务合作