# How can I get the actual position of the node on Canvas?

How can I get the actual position of the node on Canvas?
0.0 0

#1

How can I get the actual position of the node on Canvas which has multi parents with different scales and rotations. I tried “convertToWorldSpace” and “AR” recursively with node.parent until reach “Canvas”, but it seems rotations and scales are not reflected.
I believe there is easy way to get it, since the sprite on the node drawing on right position on the screen.

Thanks.
-Hiroki

#2

Hi,

I used to follow this practice:

Step 1 : Convert a node position to worldspaceAR with respect to it’s parent.
i.e var position = node.parent.convertToWorldSpaceAR(node.position);

Step 2: Convert “position” in step 1 to the nodespaceAR of the desired node (canvas in your case).
i.e position = canvasNode.convertToNodeSpaceAR(position);

Thanks,
Rahul

#3

`cc.Node.convertToWorldSpaceAR(cc.Vec2)` converts a position from node space to world space. New position is affected by node’s heirarchy scales and rotations BUT it is still a position - it does’nt contain any info about scale or transform of the node space, it’s just a point (x,y)
If you need to get node’s hierarchy cumulative total rotation and scale, I believe you can extract this data from `cc.Node.getWorldToNodeTransform()`. It returns an affine transform from world space to node space, a transform that reflects how world coordinates are mapped into node space.

#4

It went well. I finally understood how worldspaceAR() and convertToNodeSpaceAR() works

#5

Thanks persay for the additional information. I learned more how cc.Node works.